Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ADO data access to excel

Hi

Its not working :

Sub ADOImportFromAccessTable(DBFullName As String, _
TableName As String, TargetRange As Range)

Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Dim pocz, kon As Date

Set TargetRange = TargetRange.Cells(1, 1)
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
DBFullName & ";"
Set rs = New ADODB.Recordset
pocz = InputBox("Od")
kon = InputBox("Do")
With rs
.Open "SELECT * FROM " & TableName & _
" WHERE Początek pocz and koniec<kon", cn, , , adCmdText
TargetRange.CopyFromRecordset rs '
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

ADOImportFromAccessTable "c:\Baza.mdb", "Postoje",
ThisWorkbook.Worksheets("Arkusz2").Cells(1, 1)


why ???

mrjoy



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ADO data access to excel

Maybe

With rs
.Open "SELECT * FROM " & TableName & _
" WHERE Początek " & pocz & " and koniec < #" &
Format(kon,dd-mm-yyyy" &"#, cn, , , adCmdText


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"myrka" wrote in message
...
Hi

Its not working :

Sub ADOImportFromAccessTable(DBFullName As String, _
TableName As String, TargetRange As Range)

Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Dim pocz, kon As Date

Set TargetRange = TargetRange.Cells(1, 1)
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
DBFullName & ";"
Set rs = New ADODB.Recordset
pocz = InputBox("Od")
kon = InputBox("Do")
With rs
.Open "SELECT * FROM " & TableName & _
" WHERE Początek pocz and koniec<kon", cn, , , adCmdText
TargetRange.CopyFromRecordset rs '
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

ADOImportFromAccessTable "c:\Baza.mdb", "Postoje",
ThisWorkbook.Worksheets("Arkusz2").Cells(1, 1)


why ???

mrjoy





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default ADO data access to excel

"Its not working". What does that mean ?
Error, wrong results, syntax ?
You need to provide more details.

Is the filed really called "Początek" ?

NickHK

"myrka" wrote in message
...
Hi

Its not working :

Sub ADOImportFromAccessTable(DBFullName As String, _
TableName As String, TargetRange As Range)

Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Dim pocz, kon As Date

Set TargetRange = TargetRange.Cells(1, 1)
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
DBFullName & ";"
Set rs = New ADODB.Recordset
pocz = InputBox("Od")
kon = InputBox("Do")
With rs
.Open "SELECT * FROM " & TableName & _
" WHERE Początek pocz and koniec<kon", cn, , , adCmdText
TargetRange.CopyFromRecordset rs '
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

ADOImportFromAccessTable "c:\Baza.mdb", "Postoje",
ThisWorkbook.Worksheets("Arkusz2").Cells(1, 1)


why ???

mrjoy





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
How do I access the access data via Excel 2002 with auto update ? karthik Excel Programming 1 February 9th 07 01:56 PM
Importing data from Access to Excel, but I need to vary the table from Access Liz L. Excel Programming 3 June 6th 06 02:12 AM
Data too large for Excel, need to query Access data for results Susan[_4_] Excel Programming 8 March 9th 06 03:02 PM
Access data -work in Excel- save in Access s_u_resh Excel Programming 1 October 25th 04 12:52 PM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Š2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"