Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Find and Replace with a Command Button

Status
Not open for further replies.

spage7777

Programmer
Mar 19, 2007
10
US
Greetings,

I have a form with numerous fields that I am wanting to use the "Find" command on. What I am wanting to do is use a command button on the form labeled "Search". Whenever the user presses the Search button, I would like the "Find" command to be executed for whatever field the cursor is currently in. For instance, if the cursor is resting in the "First Name" field, then when the user presses the "Search" button I would like the "Find and Replace" dialog to appear so that they can't enter in a first name to search for. I realize that there is the "Find and Replace" toolbar button that I can use, but I haven't figured out how to use this with a command button. I have tried to the following "DoCmd" line of code, but to no avail. Any suggestions?

Call DoCmd.DoMenuItem(acFormBar, acEditMenu, acFindRecord, , acMenuVer70)
--
Thanks in advance!

Sherwood
 
You may try this in the Click event procedure of the button:
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFind

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top