Finding a record on a form in an ADP project

T

Thierry

Having some troulbe with a basic action. Maintenance form open with AssetID
passed in via OpenArgs. Now I want to display the specific Asset record...
Using this code it works... but I'm puzzled by the error.
----------------------
' Move the active record
If Len(Me.OpenArgs) > 0 Then
Dim rs As Variant
Set rs = Me.RecordsetClone
rs.Find "AssetID = " & Me.OpenArgs

'Check for EOF. If at EOF reset to the first position in the
'recordset. Otherwise, if a match was found, move that record and
exit.
If rs.EOF Then
rs.MoveFirst
MsgBox "Record NOT Found. Starting at the first record.",
vbExclamation
Else
On Error Resume Next ' added this to overcome a coding
issue.
Me.Bookmark = rs.Bookmark
Me.Form.Bookmark = rs.Bookmark
End If

-----------------------
YOu can see I've added the REsume Next line so I can get the code to try
both the bookmark stmts. One works when there are no maintenance records for
the asset. The other works when there are records for the asset.

Is there a better way? I welcome any and all responses. Thanks.
Thierry
 
S

Sylvain Lafontaine

Try replacing Me.RecordsetClone with Me.Recordset.Clone. Also, don't forget
that you code shouldn't work correctly for the cases where the form is past
the value of OpenArgs.
 

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