Find Record

W

Wavequation

I have a form with a subform formatted as a continuous form with records that
include a Manufacturer's Part Number (MPN) field. I am trying to write code
to enable the user to easily find one of the listed MPNs. I have placed a
command button on the form that opens another form which has a combo box
which lists all the available MPNs, and a command button. I would like the
user to select an MPN, click the command button, and the focus will be on the
record with appropriate MPN, and the dialog form will close. Here is the
code I am using for the command button on the dialog form:

Dim MPN As String
MPN = Me.Combo0
Forms!FrmBuild!FrmBuildSub.SetFocus
DoCmd.FindRecord MPN, acEntire, , acSearchAll, , acAll, True
DoCmd.Close acForm, Me.Name

When the code is run, I get error code 2162.

Any suggestions?
Thanks!
 
J

Jack Leach

You could try using a recordsetclone bookmark. something along these lines
to move to the specific record:



Dim rs As DAO.Recordset
Dim lRecord As Long

lRecord = <the record primary key to find>

Set rs = Me.RecordsetClone
rs.FindFirst "[fldID] = " & lRecord
If rs.NoMatch Then
MsgBox "The Part you have entered does not exist."
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing



hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

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