I have a form listing records in a table. The form contains an "Edit this record" button and an "Add new Record" button. Both of these forms opens a form, displaying; either the currently selected record (if "Edit this record" is clicked) or, in data entry mode, enabling a user to create a new record. On this data entry/edit form there is a "Save" button, an "Add new Record" button and a "Close Button". Provided the user has saved a newly added record, when the "Close" button is clicked, I would like to close the data entry form and navigate to the saved record in the form listing the records in the table. I don't want to filter the list. I just want to navigate to the new record in the list.
The records are created with an autonumber value (called DB_Key) which should be able to be used to look up the record in the form listing all records.
This seems like it should be straight forward to do but I'm really struggling. I know that before I try to find the record in the record list form I have to requery the form. I've got that working. I've looked at the DoCmd.OpenForm command and think that I should be passing the value of DB_Key in the OpenArgs parameter and I think I've got that correct (DoCmd.OpenForm "Main List Template", acNormal, , , acFormReadOnly, acWindowNormal, Me.txtDBKey) but I'm lost after that. I have this code in my Form_Load() subroutine of my list form;
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
DoCmd.FindRecord Me.OpenArgs, acEntire, False, acSearchAll, False, acCurrent, True
The first problem is that, although I passed a value in the OpenArgs parameter of the OpenForm command, the IsNull(Me.OpenArgs) call returns true!
Can someone help me out here?
Thanks in advance for any direction you can provide.