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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Record After Update?

Status
Not open for further replies.

miletracker

Technical User
Apr 21, 2002
46
US

I need help with code for the combo afterupdate.
This should be easy to do, after combo [Truck List] is updated and ' Truck 1' is selected the form should display the LAST record for that truck.(The table will contain the records for all trucks in the fleet).
Miletracker
 
Miletracker: You should try the DLast function; very useful. Say you can look up your truck records using an autonumber ID field (not sure what your key field is) the code might look something like this:

On the Afterupdate of the combo box:

Dim MyLstTruck As Long
MyLstTruck = DLast("[Truck_ID]","tblTrucks","[Truck1] = Forms![MyForm]![Truck_List]")

..ok, that's the LookUp part of it, now move the recordset to that record...

Set rst = Forms![MyForm].RecordsetClone
rst.FindFirst "[Truck_ID] = " & MyLstTruck
Forms![MyForm].Bookmark = rst.Bookmark
Exit Sub

...that shd do it. No doubt there's a slicker way, but this works...good luck...

 
Miletracker: One more point. The FindFirst function requires the ADO library. While you're putting in the code, go to "Tools" then "References" then scroll down and find, e.g., Microsoft ADO Library v. 3.6, and then check it off and bring it to the top of the library list. Otherwise the routine won't work.
 
Isadore thanks a million I shall try I tried thr dlookup but failed to move to recordset Miletracker
 
miletracker - one more error - its been one of those days, the dll library you need is "DAO" and not "ADO". Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top