Discussion Locked

Access DB: FindRecord Method

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have used DoCmd.FindRecord to search for an ID #. When used, it searches all Fields. If I limit it to the Current Field, it finds nothing. Does anyone have tips. See Code Below:

Private Sub cmdSearch_Click()
On Error GoTo Err_cmdSearch_Click
DoCmd.OpenForm "Book Form"
txtNum.SetFocus

If Not txtNum.Value = "" Then
DoCmd.FindRecord txtNum.Value, acDown, , acSearchAll, True, acAll
txtNum.Value = ""
DoCmd.Close acForm, "ID # Search"

4 replies

by donq

I go about FindRecord a little differently.

1st. I place a Find (binoculars button) on my form. Assess builds the code I need for me.

2nd. I create a query that finds the record I want and switch to SQL View and copy the code to the clipboard.

3rd. Then I re-open my Form and substitute my clipboard SQL Statement for the Find button statement.

CAUTION: If you need to find a variable record build a combo box to deliver ONLY filter values that are needed and place "[Forms]![FormName].[ComboBoxName] in the criteria area of the query constructed in step 2. Then have the combo box's After Update event call your report - which uses your query as its record source.

This discussion is closed to new replies.