You have two forms - frmA and frmB.
frmA is based on some table/query.
frmA has a command button cmdOpenfrmB
frmA has a textbox control txtID which stores the ID# you mentioned in your question.
frmB is based on the same table/query as frmA
In frmA you would have the following event procedure:
Private Sub cmdOpenfrmB_Click()
docmd.openform "frmB",,,,,,me.txtID
End Sub
Note:I'm not sure how many commas there are supposed to be, but the me.txtID argument is supposed to be the last one - the openargs argument.
In frmB you would have this event:
Private Sub Form_Load()
Me.RecordsetClone.FindFirst "[CategoryID] = " & Val(Me.OpenArgs)
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
What this does is creates a recordset object you can reference. This objects allows you to use methods that are reserved to recordset objects on a form which is based on a table/query.
The Val(me.openarg) the the me.txtID value you had passed in the command button OnClick event from frmA.
I used the Val procedure to convert the me.openarg to an integer value since me.openarg is a text value. If the field you specified was a text field then you would simply pu me.openarg, leaving out the val function.
The line 'Me.bookmark = me.recordsetbookmark' is what causes frmB to display the record you want it to. the findfirst method moves to the record which satisfies the criteria you specified. But in the me.recordsetclone object. The bookmark value is a sort of marker so when you assign it to the forms bookmark you make the current record of the form the same as in the recordset object. If you left out that line the form would go to teh first record.
This was a very good question. I had never tried anything like this before but I'm sure there were situations where I used much more code and created more objects to accomplish the same thing.
ntp