Dim qdfNew As QueryDef
Dim strSQL As String
strSQL = "SELECT ...."
On Error Resume Next
Set qdfNew = CurrentDb().QueryDefs("MyQuery") I
If Err.Number = 3265 Then ' "Item not found in this collection:
Set qdfNew = CreateQueryDef("MyQuery", strSQL)
Else
qdfNew.SQL = strSQL
End If
DoCmd.OpenQuery "MyQuery"

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> Doug:
> I created a QueryDef, opened a recordset, and still don't get anything
[quoted text clipped - 11 lines]
>> > choices,
>> > and then show the records (and their particular fields) retrieved.
wgaskill - 03 Jul 2006 19:20 GMT
Thanks - the Help talks about not creating new Queries, but handles a
QueryDef as a Query.
> Dim qdfNew As QueryDef
> Dim strSQL As String
[quoted text clipped - 27 lines]
> >> > choices,
> >> > and then show the records (and their particular fields) retrieved.
Douglas J. Steele - 03 Jul 2006 21:51 GMT
Afraid I don't understand your comment.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> Thanks - the Help talks about not creating new Queries, but handles a
> QueryDef as a Query.
[quoted text clipped - 32 lines]
>> >> > choices,
>> >> > and then show the records (and their particular fields) retrieved.