By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

Predefined "Look In" in Find dialog box works, but not 1st time

P: n/a
I use the undermentioned code to find a record in a predefined "Look
In" field:

Private Sub Command137_Click()
On Error GoTo Err_Find_Record_Click
Me.CompanyName.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Find_Record_Click:
Exit Sub
Err_Find_Record_Click:
MsgBox Err.Description
Resume Exit_Find_Record_Click
End Sub

However, the Look In field of the find-record dialog
box is first set a the form name, not the field name as mentioned in
the code (SetFocus).
Though, it happens only when I approached the form for the first time
after I
start Access. Why?

Bart

Jun 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I quit using, or answering questions about "DoMenuItem" some time ago.

If you want to find the record with a particular value in a Control on the
currently-displayed form, you might try:

Me.RecordsetClone.FindFirst "[yourfieldname] = """ & Me.yourcontrolname
& """"
Me.Bookmark = Me.RecordsetClone.Bookmark

(Of course, you must replace yourfieldname with the name of the Field in
your Record and you must replace yourcontrolname with the name of the Field
on your Form.)

(This code assumes the field of interest is text, so the argument of
FindFirst must be in quotation marks. If it is a numeric field, eliminate
two of the string of three quotes, and the entire & """" at the end of the
string.)

(And, a final "of course", the record of interest must exist in the Form's
RecordSource.)

Larry Linson
Microsoft Access MVP


"AA Arens" <ba***********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I use the undermentioned code to find a record in a predefined "Look
In" field:

Private Sub Command137_Click()
On Error GoTo Err_Find_Record_Click
Me.CompanyName.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Find_Record_Click:
Exit Sub
Err_Find_Record_Click:
MsgBox Err.Description
Resume Exit_Find_Record_Click
End Sub

However, the Look In field of the find-record dialog
box is first set a the form name, not the field name as mentioned in
the code (SetFocus).
Though, it happens only when I approached the form for the first time
after I
start Access. Why?

Bart

Jun 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.