Posted on 2012-03-16
Not sure if this is the right way to do this but... When I open certain forms I want to automatically restore to the last record displayed prior to closing the form. I have a table with fields having the "Last" record edited for various forms. The table will always have 1 record and the fields represent the "Last" record on specific forms displayed before closing the form. The table is called tblLastRecordNo and a form with a respective query display the 1st (and only) record. This form will be hidden as there is no need for it to be visible.
To make things less complicated, the "Last Record Numbers" form is a subform (not visible) in the form I want to automatically restore to the "Last record displayed". I use the SearchForRecord macro but it doesn't work. It doesn't find the record and I have a feeling it has to do with field types. In the SearchForRecord macro where I enter the Where Condition it looks like this:
[autonumCustomerId] = Forms![frmEquipmentEdit]![frmLastRecordNo1].Form![numCustomerLast]
It doesn't find it. If I enter:
[autonumCustomerId] = 22
it will find the correct record. Which leads me to believe there is a number "Type" problem.
[autonumCustomerId] in my Customer table is AutoNumber.
[numCustomerLast] is a numeric field, Long Integer in tblLastRecordNumber.
I am not a VBA expert so I prefer to use macros when possible. This seems like such a simple problem but I can't make it work.
Any help is appreciated.