I would like to create a temporary query that a form can use when it opens.
Of course the reason it is temporary is that the query can change each time the form opens.
I found this code in here (this forum).
Which seems like a good start except
I'm getting a "Item not found in this collection" at Set qdf = db.QueryDefs("qryMyQuery")
and... it is temporary?
Any help would be appreciated.
Of course the reason it is temporary is that the query can change each time the form opens.
I found this code in here (this forum).
Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strMySQL As String
Set db = CurrentDb
[COLOR="Red"][B]Set qdf = db.QueryDefs("qryMyQuery")[/B][/COLOR]
strMySQL = ""
strMySQL = strMySQL & "SELECT Field1, Field2 "
strMySQL = strMySQL & "From MyTable "
qdf.SQL = strMySQL
Set qdf = Nothing
Set db = Nothing
Which seems like a good start except
I'm getting a "Item not found in this collection" at Set qdf = db.QueryDefs("qryMyQuery")
and... it is temporary?
Any help would be appreciated.