Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this code:
Dim Data1 As ADODB.Recordset Dim Connect As String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\db1.mdb;" Set Data1 = New ADODB.Recordset Data1.Open "[Test Q]", Connect Sheets(1).Range("A1").CopyFromRecordset Data1 The Query "Test Q" works in Access and I get an output there. But when I run it in here, nothing is copied over. The script works if I put a table in there. Why is this happening? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this instead "Test Q"
"J@Y" wrote: I have this code: Dim Data1 As ADODB.Recordset Dim Connect As String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\db1.mdb;" Set Data1 = New ADODB.Recordset Data1.Open "[Test Q]", Connect Sheets(1).Range("A1").CopyFromRecordset Data1 The Query "Test Q" works in Access and I get an output there. But when I run it in here, nothing is copied over. The script works if I put a table in there. Why is this happening? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My code for Test Q:
SELECT * FROM VTABLE WHERE VTABLE.ID between (Select VTABLE.ID FROM VTABLE Where VTABLE.Account = "2") AND (Select MIN( VTABLE.ID) From VTABLE WHERE VTABLE.Name like "*000000000*" AND VTABLE.ID ( Select VTABLE.ID FROM VTABLE Where VTABLE.Account = "2")); I think something doesn't work for excel here, I tried breaking apart this into parts and each part worked..... "Mike" wrote: Try this instead "Test Q" "J@Y" wrote: I have this code: Dim Data1 As ADODB.Recordset Dim Connect As String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\db1.mdb;" Set Data1 = New ADODB.Recordset Data1.Open "[Test Q]", Connect Sheets(1).Range("A1").CopyFromRecordset Data1 The Query "Test Q" works in Access and I get an output there. But when I run it in here, nothing is copied over. The script works if I put a table in there. Why is this happening? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After alot of testing, the problem was Excel VB doesn't recognize Like
"*0000000*". Instead of *, Excel uses %. This makes the Query not work in Access, but works in Excel. "J@Y" wrote: My code for Test Q: SELECT * FROM VTABLE WHERE VTABLE.ID between (Select VTABLE.ID FROM VTABLE Where VTABLE.Account = "2") AND (Select MIN( VTABLE.ID) From VTABLE WHERE VTABLE.Name like "*000000000*" AND VTABLE.ID ( Select VTABLE.ID FROM VTABLE Where VTABLE.Account = "2")); I think something doesn't work for excel here, I tried breaking apart this into parts and each part worked..... "Mike" wrote: Try this instead "Test Q" "J@Y" wrote: I have this code: Dim Data1 As ADODB.Recordset Dim Connect As String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\db1.mdb;" Set Data1 = New ADODB.Recordset Data1.Open "[Test Q]", Connect Sheets(1).Range("A1").CopyFromRecordset Data1 The Query "Test Q" works in Access and I get an output there. But when I run it in here, nothing is copied over. The script works if I put a table in there. Why is this happening? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "J@Y" wrote: I have this code: Dim Data1 As ADODB.Recordset Dim Connect As String Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\db1.mdb;" Set Data1 = New ADODB.Recordset Data1.Open "[Test Q]", Connect Sheets(1).Range("A1").CopyFromRecordset Data1 The Query "Test Q" works in Access and I get an output there. But when I run it in here, nothing is copied over. The script works if I put a table in there. Why is this happening? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Import Data from Access query | Excel Discussion (Misc queries) | |||
Database query to import from Access to Excel | Excel Discussion (Misc queries) | |||
access query to import to excel | Excel Worksheet Functions | |||
Import from Access query with prompts | Excel Discussion (Misc queries) | |||
Import query from Access | Excel Discussion (Misc queries) |