How to get latest record for item

P

Paul B.

I have a table 'tblVehicles' which holds 'dispositions' for each vehicle. I
need to display only vehicles that hold the 'disposition' of available. My
problem is I get several records for each vehicle. For example the table
holds 'dispositiondate' and 'disposition' so everytime a record is entered
with a disposition of available, it shows in my form. I only want the last
entry.

So, I was thinking of using DLast such as :

DLast("[Disposition]","tblDispositions","[VehicleNumber]="&_
[Forms]![frmVehicleDispositions]![VehicleNumber])

Question is, how would I add the second argument to show vehicle with a
'disposition' of 'available'

Thanks in advance
 
M

Marshall Barton

Paul B. said:
I have a table 'tblVehicles' which holds 'dispositions' for each vehicle. I
need to display only vehicles that hold the 'disposition' of available. My
problem is I get several records for each vehicle. For example the table
holds 'dispositiondate' and 'disposition' so everytime a record is entered
with a disposition of available, it shows in my form. I only want the last
entry.

So, I was thinking of using DLast such as :

DLast("[Disposition]","tblDispositions","[VehicleNumber]="&_
[Forms]![frmVehicleDispositions]![VehicleNumber])

Question is, how would I add the second argument to show vehicle with a
'disposition' of 'available'


You should use DMax instead of DLast.

You never explained how the form got involved in the
criteria of the query, but I think the dispositiondate
field's criteria should be:

DMax("dispositiondate","tblDispositions","VehicleNumber=" &
tblVehicles.VehicleNumber & " And Disposition='available'")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Second arguement to DLast 9
SQL string help 3
Save user input NOT default 1
Link duplicate fields 2
Where to start 2
Ready to Start (For Real) 2
Form/Sub Form 1
Combine Two Fields Values for Totals Report 1

Top