I have received some help with my problem as you can see below after the original question but I continue to receive a Compile Error: User defined type-not defined when I click on the command button “next” on form 1. The code on the next form was entered as suggested below in the reply. It highlights the “Dim rs As DAO.Recordset” and I get the Compile error above. Can you please help me it would be greatly appreciated.
Reply 1:
If I understand you correctly, you need to pass the primary keyfield from one form to another, then force the second form to jump to that correct record. You can pass the key field to the next form using the OpenArgs property,
e.g.
DoCmd.OpenForm “next form”,acNormal,,,,, Me![key field]
In the OnLoad event of the next form,
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst “[key field] = ” & Me.OpenArgs
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
—
Hope this helps
Tony Oakley (MVP)2nd REPLY:
You place that code in your command button’s onclick event procedure passing the information about the current record you are currently processing to the next form.
DoCmd.OpenForm “[next form]”, acNormal,,,,,Me![primary key field]
In the Onload event procedure of the next form, you go forward (or back) to the record you are processing in your previous form. For example, you are already at the record 3, and when you click on the next button, you want the next form to show up records for record 3. You do this by:
Dim rs as DAO.Recordset
set rs = Me.RecordsetClone
rs.FindFirst “[primary key field]=” & Me.OpenArgs
If Not rs.NoMatch then
me.bookmark = rs.bookmark
end if
set rs = nothing
The findfirst method above finds record 3 and set’s the current bookmark to that record for the next record.