Dlookup & Max (1 Viewer)

kermit

Registered User.
Local time
Today, 04:42
Joined
Dec 20, 2002
Messages
12
I am trying to get a Dlookup function to pull one number from a table(trackopupdate). I want to give it a specific item and op(two fields in my table) and i want it to return the largest ID(autonumber) that exists in the table for that item and op.

here's what i have now:

RevRec = DLookup("Max([ID])", "TrackOpUpdate", "Item_Nbr = " & Item & "And Op_Nbr = " & op)

any help would be greatly appreciated...

-kermit
 

FoFa

Registered User.
Local time
Today, 04:42
Joined
Jan 29, 2003
Messages
3,672
RevRec = DMax("[ID]", "TrackOpUpdate", "Item_Nbr = " & Item & "And Op_Nbr = " & op)
 

WayneRyan

AWF VIP
Local time
Today, 10:42
Joined
Nov 19, 2002
Messages
7,122
kermit,

You have duplicates in your table, this will make life tougher
for you.

I take it that in the set of records that share the same Item_Nbr
and Op_Nbr, the one with the highest number is the latest
"revision". If that's the case then you should add a revision
field.

However, with your current data, you can use the DMax function
to retrieve your highest value.

That might work for now, but your original design should
change. The AutoNumber fields should only be used to give
a unique identifier. They can't be "trusted" to convey info
such as the presence of the latest revision.

Wayne
 

nebon

Registered User.
Local time
Today, 10:42
Joined
May 14, 2003
Messages
51
hallo there ... I noticed you forgot to place the quotes "'" ...
try this ...

DLookup("Max([ID])", "TrackOpUpdate", "[Item_Nbr] = " & "'" & Item & "'" & " And [Op_Nbr] = " & "'" & op & "'")
 

Users who are viewing this thread

Top Bottom