Double Click Open Form to Record Number

T

Tim

Hello,
Please assist me with an Access procedure; I am working with Access 2003,
Window XP Professional. I have a form name frmPending with a field name
RecordNumber. I would like to double click on the field name RecordNumber
and open a form name frmInventory to the record number specified on
frmPending.
 
T

Tom van Stiphout

This is how I do that: I pass in the value via the OpenArgs argument
to DoCmd.OpenForm, and then in the Form_Load of the second form
position the recordset to that record. The code:

DoCmd.OpenForm "frmInventory",,,,,Me.RecordNumber 'I hope that was
enough commas to get to the OpenArgs argument

Then in Form_Load of frmInventory:
if Len(Me.OpenArgs)>0 then
with Me.RecordsetClone
.FindFirst "RecordNumber=" & Me.OpenArgs
if .NoMatch then Msgbox "Aaaarrrccchhhh!!!"
else
Me.Bookmark = .Bookmark
end if
end with
end if

If you don't care about the cool ability to scroll to other records,
there is a much simpler solution, the one-liner:
DoCmd.OpenForm "frmInventory",,,"RecordNumber=" & Me.RecordNumber

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top