Where clause using max of (1 Viewer)

WineSnob

Not Bright but TENACIOUS
Local time
Yesterday, 19:25
Joined
Aug 9, 2010
Messages
211
I am trying to open a form using the where clause to max of a table field.
I cannot get the syntax correct.

Code:
 DoCmd.OpenForm "frmInput", , , Max(tblClients.ClientID) AS MaxOfClientID FROM tblClients
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:25
Joined
Aug 30, 2003
Messages
36,126
Something like

"ClientID = " DMax("ClientID","tblClients")
 

plog

Banishment Pending
Local time
Yesterday, 18:25
Joined
May 11, 2011
Messages
11,646
MAX is a SQL function, you can't use SQL right there. Instead you should use the DMAX function (http://www.techonthenet.com/access/functions/domain/dmax.php).

However, that's just going to return a value, you need to set a value from the form equal to it to use as criteria. What field in the form do you want to equal the value?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:25
Joined
Aug 30, 2003
Messages
36,126
Happy to help!
 

Users who are viewing this thread

Top Bottom