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!

MS Access Find and Replace Feature Problems?

Status
Not open for further replies.

tomcat22

Technical User
Dec 6, 2006
2
CA
I created a cmd button to run the Find and Replace feature on a MS Access Form. The form has several fields, text fields and list/combo boxes. The find feature works ok for the first text field -"Title" and searches all relevant records in the db, but it does not work for the other fields on the form.

Has anyone else run into this problem and do you have any advice on how to rectify this?

Thanks!
 

Here's the routine I use for this job. Just click on the field to be searched then on the Find button:

Code:
Private Sub FindStuff_Click()
  [b]Screen.PreviousControl.SetFocus[/b] 
  SendKeys "%ha%n", False
  DoCmd.RunCommand acCmdReplace
End Sub

The bold line is the answer to your problem, I think. Once you click on the Find Button, it takes focus back to whichever control had focus immediately before you clicked on the Find Button, then runs the Find/Replace routine.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thank you so much...code provided works fine....part of the problem was also that I was using a subform which was under the detail section and the main form was in the Header Section. I deleted the subform and copied its controls to the detail section and the Find feature now works on all fields?

Go figure? I am learning as I go on the fly.

Your help is really appreaciated!
 
That's why we're here!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top