Open form to certain record but also pull other record from table

I

insideout786

I want to open a form based on input in textbox. I have that part
working with docmd.open, but it actually filters the table and only
returns one record.

My problem is that I want to open a form to specifc record but also
have other records avaliable from the table, so I can go to next and
previous record.

HELP!!!!!
 
R

ruralguy via AccessMonster.com

If you are using at least ac2K then you can use the OpenArgs argument. Do
not use the WhereCondition argument and pass the value in the OpenArgs
argument of the OpenForm command. VBA Help will show you where to put it. In
the next form put the following in the Load event (the Open event is too
early):

If Not IsNull(Me.OpenArgs) Then
' Find the record that matches the Argument
'-- If [YourField] is numeric then use the following
Me.RecordsetClone.FindFirst "[YourField] = " & Me.OpenArgs
'-- If [YourField] is a text field then use this instead
'Me.RecordsetClone.FindFirst "[YourField] = " & Chr(34) & Me.OpenArgs &
Chr(34)
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End If

This requires a reference to DAO and replacing [YourField] with your actual
field name.
 
Top