My goal is to create a QueryDef by vba, that is the same as I can create in the GUI.
This are the Steps, that I use in the GUI:
- Create the query
- Set it as passthrough
- Set the ODBC connection string
- Enter the statement
How can I set this by VBA and use the queryDef as RecordSource in the current form?
Dim qdf As QueryDef
Set qdf = CurrentDb.CreateQueryDef("test", "select * from test;")
'passthrough?
'connection string?
'set as RecordSource?
I found out, that there is a Properties-Collection. When I investigate a GUI-made query, I see that there the connection-String is in item 6:
Debug.Print qdfTmp.Properties.Item(6).Name
> Connect
You can find the other setting alos, but I do not know how to set them with VBA.