How to select the maximum value (1 Viewer)

Crash_Pie

Registered User.
Local time
Today, 12:26
Joined
Feb 15, 2007
Messages
36
Hi all

I have an expression in a query which is checking a list box on a form. If the list box is empty (is null), then I would like the query to search on the highest (maximum) value in the specified field (CourseFK), otherwise it will look for the value in the list box.

Code:
Expr1: IIf([Forms]![frmEditDeleteStudentDetails]![lstEditCourseFK] Is Null,[CourseFK]=Max([CourseFK]),[CourseFK]=[Forms]![frmEditDeleteStudentDetails]![lstEditCourseFK])

However it seems Access will not allow me to do this - I get an error about an aggregate function in a where clause.

Can someone please suggest to me how to get around this? Eg, is there an alternative way to search for the maximum (still needs to be determined dependant on the list box).

Thanks
 

KenHigg

Registered User
Local time
Yesterday, 20:26
Joined
Jun 9, 2004
Messages
13,327
Seems you may be able to squeeze a dmax() fuction in there somewhere....

ken:)
 

Crash_Pie

Registered User.
Local time
Today, 12:26
Joined
Feb 15, 2007
Messages
36
Thanks Ken

Worked a treat! :)
 

Users who are viewing this thread

Top Bottom