Another DoCmd.OpenForm Question

G

Gordon

Hey All,

I'm trying this and can't seem to make it work.

DoCmd.OpenForm , , , " CCSD LIKE '*something*' ORDER BY [date] "

Is the ORDER BY illegal in this instance?

Thanks,

G
 
V

Van T. Dinh

AFAIK, yes since the "WhereCondition" argument is expected to be a WHERE
Clause without the word "Where", not an ORDER BY Clause.

If you want to sort the Records, put the ORDER BY Clause in the RecordSource
Query or you can use code to set the OrderBy and OrderByOn Properties of the
Form.

Check Access VB Help on the above 2 Properties.
 
F

fredg

Hey All,

I'm trying this and can't seem to make it work.

DoCmd.OpenForm , , , " CCSD LIKE '*something*' ORDER BY [date] "

Is the ORDER BY illegal in this instance?

Thanks,

G

DoCmd.OpenForm "FormName" , , , "CCSD LIKE '*something*'"
forms!FormName.OrderBy = "DateField"
forms!FormName.OrderByOn = True
 
Top