BigOrangeMonkey
Programmer
Can I set a pass through query to not return any rows via VB Code using ADO?
I need to refresh all the links before the queries are run as the ODBC settings may change, i.e. A customer has multiple databases holding the same info (Test and Live) so the same Queries have to be run on different databases with minimal user interaction.
If I set the flag in the Access Properties Box to NO it gets reset during this code!
Current Code :
Cheers,
Steve.
I need to refresh all the links before the queries are run as the ODBC settings may change, i.e. A customer has multiple databases holding the same info (Test and Live) so the same Queries have to be run on different databases with minimal user interaction.
If I set the flag in the Access Properties Box to NO it gets reset during this code!
Current Code :
Code:
Sub ModifyQuery(strQryName As String, _
strConnection As String)
Dim catdb As ADOX.Catalog
Dim cmd As ADODB.Command
Set catdb = New ADOX.Catalog
' Open the Catalog object.
catdb.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.CurrentProject.FullName
Set cmd = New ADODB.Command
'Get the query from the Procedures collection.
Set cmd = catdb.Procedures(strQryName).Command
' Update the query's SQL statement.
With cmd
.Properties("Jet OLEDB:ODBC Pass-Through Statement") = True
.Properties("Jet OLEDB:Pass Through Query Connect String") = strConnection
End With
'Save the updated query.
Set catdb.Procedures(strQryName).Command = cmd
Set catdb = Nothing
End Sub
Cheers,
Steve.