Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Through Queries and ReturnsRecords with ADO

Status
Not open for further replies.

BigOrangeMonkey

Programmer
Aug 27, 2002
26
GB
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 :
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top