Open Query with VBA

  • Thread starter Thread starter Guest
  • Start date Start date
depends on what kind of query it is.
If you want to run an Action (append, delete, make table, update) then the
fastest method is:
CurrentDb.Execute("QueryNameGoesHere"),dbFailOnError
For many reasons it is better than the DoCmd.RunSQL

To use select queries, you have to use a recordset.

Set rst = CurrentDb.OpenRecordset("QueryNameGoesHere")
 
Sorry, What I'm tring do is. I have a 10 set of query I would like to open up
in a from a list field. Here what I came up with but it dose not work

rivate Sub RoyaltyReports_Click()
Dim qdfs As QueryDefs
Dim qdf As QueryDef
Dim strQry As String
Set qdfs = CurrentDb.QueryDefs
For Each qdf In qdfs
If Left(qdf.Name, 1) <> "~" Then 'Filter out internal queries
strQry = strQry & qdf.Name & ";"
End If
Next qdf
strQry = Left(strQry, Len(strQry) - 1)
Me.Vendor.RowSource = strQry
Set qdfs = Nothing
Set qdf = Nothing


Thank You
 
Hello, What I was tring to do was: I have list of name the I would like to
assoicate the query to selt and run with the assocation, I have something but
it not working.

rivate Sub RoyaltyReports_Click()
Dim qdfs As QueryDefs
Dim qdf As QueryDef
Dim strQry As String
Set qdfs = CurrentDb.QueryDefs
For Each qdf In qdfs
If Left(qdf.Name, 1) <> "~" Then 'Filter out internal queries
strQry = strQry & qdf.Name & ";"
End If
Next qdf
strQry = Left(strQry, Len(strQry) - 1)
Me.Vendor.RowSource = strQry
Set qdfs = Nothing
Set qdf = Nothing

Thank You
Jeffrey
 
Back
Top