Find Record

S

Steve S

I have a form that is based on a query and I want to create a button on the
form to find a particular record based on criteria that I input into a field
either in a message box or pop-up form. Can someone help me with the
docmd.find coding to accomplish this? Thanks in advance.
Steve S
 
V

Vantastic

Try this:

FindField is the Field you want to search, ie CustomerName
txtSearch is your search text field the user types into

Private Sub cmdFind_Click()
On Error GoTo err_Handler

FindField.SetFocus

If FindField.SelText = txtSearch Then
DoCmd.FindNext
Else:
DoCmd.FindRecord txtSearch, acAnywhere, , acSearchAll, , acCurrent
End If

err_Handler:
Exit Sub

End Sub
 

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