How to re-define or change a set query?

  • Thread starter Thread starter Paul Mak
  • Start date Start date
P

Paul Mak

I want to use code to re-define or change a set query I created earlier.
 
Create a module and make a function or sub to set the query's sql property
equal to a string variable with the new sql statements:

Sub ChangeQuery()
Dim strSQL As String
Dim qdf As DAO.QueryDef

strSQL = "SELECT Field1 FROM Table1;"
Set qdf = CurrentDb.QueryDefs("qryTest")
qdf.SQL = strSQL
Set qdf = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top