Dear Doug Steele,
"Douglas J. Steele" wrote
> Are you saying that the query has a connection?
Yes, i've, wortly: query for a connection(Connection.CreateQueryDef),
please don't mix with QueryDef.Connect.
>In other words, it's a pass-through query?
AFAIK only for Jet workspaces.
>In that case, you can't use parameters at all.
>
> Pass-through queries run at the server, and therefore know nothing about
> what values have been passed.
>
In my knowledge pass-through doesn't deal with query object.
It 's only art of query execution - my subjectiv point of view.
But let us try a example...
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
[SNIP]
Demonstration: use parametrized ODBCDirect query
Sub test()
With DBEngine.CreateWorkspace("Test", "sa", vbNullString, dbUseODBC)
With .OpenConnection(Empty, dbDriverComplete, False, "ODBC;DRIVER={SQL
Server}; SERVER=local;DATABASE=pubs; UID=sa;")
With .CreateQueryDef(Empty, "SELECT TABLE_NAME FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?")
Debug.Print .Connect
.Parameters(0).value = "authors"
With .OpenRecordset()
If Not .EOF Then Debug.Print .Fields(0), " table found"
End With
End With
End With
End With
End Sub
It's run fine.
Regards,
Hermann