PC Review


Reply
Thread Tools Rate Thread

ADO data access to excel

 
 
myrka
Guest
Posts: n/a
 
      17th Apr 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      17th Apr 2007
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" <(E-Mail Removed)> wrote in message
news:f03ca8$9tm$(E-Mail Removed)...
> 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 With Quote
 
NickHK
Guest
Posts: n/a
 
      18th Apr 2007
"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" <(E-Mail Removed)> wrote in message
news:f03ca8$9tm$(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Access Data to Excel/Reimport modified data into Access mlloulou Microsoft Access External Data 5 9th Feb 2009 12:09 PM
Excel form to update data from MS Access data table based on criteriain excel sheet Santa-D Microsoft Excel Programming 2 13th May 2008 03:43 AM
Import Data From Access to Excel - Return Modified Data To Access HVG Microsoft Access External Data 0 9th Dec 2005 08:00 PM
Data From Excel to Acess: Overriding Access assigned data types John Faughnan Microsoft Access External Data 0 1st Jun 2004 08:38 PM
Importing excel into access - want access to update data supplied from excel Deborah Microsoft Access External Data 1 30th Jul 2003 01:21 PM


Features
 

Advertising
 

Newsgroups
 


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