Discussion Locked

Access Form Navigation

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I posted a question on Microsoft Discussion Group and received a reply below to help my question also below. Can anyone please help a inexperienced vba individual get thru these steps. I am not sure where to place the code or how with the write statements. Thank you very much in advance.

Carl
carljohnman1819@msn.com

Question:

I was given a large form our company employees use to handwrite information into for the county courts. He ask me to create it in MS Access so it would be easier to locate specific dates, names, and status, extc. I broke the form down into 7 smaller forms which looks ok and stores the information ok but I can not figure out how to make the records match up or force the next one to default to the same record the previous one was on. I placed next command buttons on each form but when you click it it takes you to the next form record 1 not the next form record "3" I was finished entering information
on in the previous form. Can anyone please help?

Reply:

If I understand you correctly, you need to pass the primary key field 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)

3 replies

by r. a. caluste

Tony's advice is neat. 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 keyfield]

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 toshow 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.

Hope I was able to explain Tony's neat code well.

by carljohnman

Thank you very much. It is always very helpful to a novice to have these steps detailed. I ran into one problem which I received assistance on. I needed to add the Microsoft DAO 3.6 Object Library. Thanks again, your help was greatly appreciated.Carl Johnman
carljohnman1819@msn.com

This discussion is closed to new replies.