Ordering a dynamic query

DBL

Registered User.
Local time
Today, 23: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.
 
You are missing a SPACE before "Order BY...

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

JR
 
Doh! Thank you so much.
 

Users who are viewing this thread

Back
Top Bottom