dlookup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all.

I use dlookup in a form to find data in a table.
This works fine if it wasnt for one small problem.
I am about to add some fields in the table, and thats when the problem show
up.

There are several answers for it to find.
Access picks the first record by default.
I would like Access to pick the last one instead.

Is there any easy way to change this, or do I have to use something else
than dlookup to solve this?

/Claes
 
Hello all.

I use dlookup in a form to find data in a table.
This works fine if it wasnt for one small problem.
I am about to add some fields in the table, and thats when the problem show
up.

There are several answers for it to find.
Access picks the first record by default.
I would like Access to pick the last one instead.

Is there any easy way to change this, or do I have to use something else
than dlookup to solve this?

/Claes

What determines which is the first or which is the last?
What is the criteria?

You need to add a Where Clause to the DLookUp (or DMax) to tell Access
which record you want to return.

For instance, to return the last name of an employee with an Employee
ID of 123, write:
=DLookUp("[EmployeeLastName]"."TableName","[EmployeeID] = 123")

To return the last dated entry for EmployeeID # 123
=DLookUp("[SomeField]","TableName","DMax('[DateField]','TableName')
and [EmployeeID] = 123")

Look up the DLookUp() and DMax() functions, as well as
Restrict data to a subset of records
in VBA help
 
Back
Top