How to lookup last record id and take value from another field of that record (1 Viewer)

bruceblack

Registered User.
Local time
Today, 12:08
Joined
Jun 30, 2017
Messages
119
Hi everyone! Some basics that i cant seem to find if its out there.
Ive been searching but cant find it. Maybe someone can explain?


I have a table with an "ID" field and a "COUNTRY" field.

How can i get the highest ID, and get the value thats in COUNTRY of that record?

I would like this in VBA, not a query builder :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:08
Joined
Sep 21, 2011
Messages
14,038
Dmax for the ID and then Dlookup for the Country. ?

Combine them even, in the Dloookup perhaps.?
 

bruceblack

Registered User.
Local time
Today, 12:08
Joined
Jun 30, 2017
Messages
119
Ah thanks gasman :)

I looked up combining them. Got it to work.

Final code:


Code:
stringname = DLookup("NumberNeeded", "table1", "[ID] = DMax('[ID]','table1')")

Thanks!!!!!
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:08
Joined
Sep 21, 2011
Messages
14,038
Interesting.
I would have gone with
Code:
stringname = DLookup("NumberNeeded", "table1", "[ID] = " & DMax("ID","table1"))
but as long as it works, that is the main thing.
 

Users who are viewing this thread

Top Bottom