Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DLookup to return the max value

Status
Not open for further replies.

dafyddg

Programmer
Dec 2, 2003
92
GB
Hi,

I'm trying to retieve the ID of the most recent invoice i have created in my Invoices table. The form i'm working from does not have its record source set to the invoices table and this can't change.

I was thinking of using the following code

Dim invid As Integer

invid = DLookup("[InvoiceID]","Invoices","Max[InvoiceID]")

However after trying something similar in a test database i found that it didn't work.

All i need is a way of getting the highest value of InvoiceID into an integer.

Please help
 
Hi,

Use the DMax function instead of DLookup. The syntax is exactly the same as DLookup, all you need to change is the function name.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top