Ordering a dynamic query (1 Viewer)

DBL

Registered User.
Local time
Today, 18:40
Joined
Feb 20, 2002
Messages
659
I'm trying to add in an order when I create a dynamic query. This is the code I currently use which creates the dynamic query:

Set QD = db.CreateQueryDef("qryFrmSelectAreas_Dynamic", _
"Select * from tblLookupAreas")

I'm trying to add in a sort by changing this to:

Set QD = db.CreateQueryDef("qryFrmSelectAreas_Dynamic", _
"Select * from tblLookupAreas" & _
"order by tblLookupAreas.Area ASC;")

But I'm just getting a Syntax error. Any suggestions as to where I'm going wrong.
 

JANR

Registered User.
Local time
Today, 19:40
Joined
Jan 21, 2009
Messages
1,623
You are missing a SPACE before "Order BY...

Set QD = db.CreateQueryDef("qryFrmSelectAreas_Dynamic", _
" Select * from tblLookupAreas" & _
" order by tblLookupAreas.Area ASC;")

JR
 

DBL

Registered User.
Local time
Today, 18:40
Joined
Feb 20, 2002
Messages
659
Doh! Thank you so much.
 

Users who are viewing this thread

Top Bottom