0
votes

I have a table which has 5 forms (form1, form2, form3, form4, form5). What I want to do is open a form to a specific record based on the id of the previous form. So say I open form1 with a record id of 15, I want to click a button which opens form2 to record id 15. By record id, I mean the ID in the main table. I am using the code below but it keeps opening form2 to a new record instead of the same record id as form1. Can anyone help please ?

Private Sub Command110_Click()
Dim recordID As Integer

   recordID = Me.ID
   MsgBox (recordID)

   DoCmd.OpenForm "Form2", , , "ID = " & recordID

End Sub
1

1 Answers

1
votes

If by recordID, you mean the record number that is shown at the bottom of the screen, it is not going to work. You need to use a field name, so :

 DoCmd.OpenForm "Form2", , , "ID = " & AFieldThatMatchesID

To test, you can use a number that you are sure is an ID in form2:

 DoCmd.OpenForm "Form2", , , "ID = " & 7

You will save to save a new record before you try to open the next form:

 Me.Dirty = False