Hello:
I am trying to send a pass-through Query via two Access mdbs. I typically use only VB 6.0 for all of my OBDC/DSN connections, so I am not sure what the differences are exactly when doing an Access-to-Access connection versus an ODBC/ADO VB 6.0 dbs.open ("DSN=name" call.
Via this code, the query is passed and the code does not throw any errors. But, when I try to open the Query I get the error message:
ODBC - - Connection to 'Switch' Failed.
Can anyone help me pass this query? It seems my ODBC statement in Access is not correct. Please advice .
Martin K
CODE:
Private Sub Command55_Click()
Dim dbsCurrent As Database
Dim qdfPass As QueryDef
Dim StrMsg As String
Set dbsCurrent = OpenDatabase("M:\OOTSSwitch"
Set qdfPass = dbsCurrent.CreateQueryDef("TestData"
qdfPass.Connect = "ODBC;DSN=Switch"
qdfPass.SQL = "Select * from CallData where Office = 'OOTS'"
qdfPass.ReturnsRecords = True
dbsCurrent.Close
StrMsg = "A connection was created."
MsgBox (StrMsg), vbInformation
End Sub
I am trying to send a pass-through Query via two Access mdbs. I typically use only VB 6.0 for all of my OBDC/DSN connections, so I am not sure what the differences are exactly when doing an Access-to-Access connection versus an ODBC/ADO VB 6.0 dbs.open ("DSN=name" call.
Via this code, the query is passed and the code does not throw any errors. But, when I try to open the Query I get the error message:
ODBC - - Connection to 'Switch' Failed.
Can anyone help me pass this query? It seems my ODBC statement in Access is not correct. Please advice .
Martin K
CODE:
Private Sub Command55_Click()
Dim dbsCurrent As Database
Dim qdfPass As QueryDef
Dim StrMsg As String
Set dbsCurrent = OpenDatabase("M:\OOTSSwitch"
Set qdfPass = dbsCurrent.CreateQueryDef("TestData"
qdfPass.Connect = "ODBC;DSN=Switch"
qdfPass.SQL = "Select * from CallData where Office = 'OOTS'"
qdfPass.ReturnsRecords = True
dbsCurrent.Close
StrMsg = "A connection was created."
MsgBox (StrMsg), vbInformation
End Sub