I create a Pass-Through Query name "qryPT", and set its ODBC connect string as
"ODBC;DRIVER=SQL Server;SERVER=luenkeesql;UID=sa;PWD=sqladmin;DATAB ASE=LuenKeeSystem" in the Property Window.
It works well on below coding.
Code:
QueryServer "select * from customer"
Sub QueryServer(SQLStatement As String)
Dim db As DAO.Database
Dim qDef As QueryDef
Set db = CurrentDb()
Set qDef = db.QueryDefs("qryPT")
qDef.sql = SQLStatement
Set qDef = Nothing
Set db = Nothing
End Sub
But how can I put the connect string inside the Sub QueryServer?
So that I don't need to recreate the Pass-Through Query "qryPT"
Thanks