Open Find/Replace Dialog Box (1 Viewer)

aaronmib

Registered User.
Local time
Yesterday, 18:00
Joined
Oct 13, 2011
Messages
14
Using VBA, how do I open the Find/Replace dialog box when I click on a button? Additionally, I want the default "Match" value to be "Any Part of Field"
 

PhoenixofMT

Part-time Access Guru
Local time
Yesterday, 18:00
Joined
Jul 23, 2008
Messages
35
Probably a bit late, but here's how I did it:
Code:
  Me.<control to find in>.SetFocus
  DoCmd.RunCommand acCmdFind
  SendKeys "%HS%N", False
I believe SendKeys is the only way to do this. The "%" means the Alt key, so it basically sends Alt+H (for the match dropdown), S (for "Start of Field", you would change this to A), and Alt+N (to move the focus back to the "Find What:" field), False returns control to the procedure without waiting for additional keystrokes. Type "sendkeys" into the VBA window and hit F1 for the full rundown. Note that using SendKeys is considered bad practice (though I think it's unavoidable here).

You should also know that Access will make the Replace tab available for your users to replace all found values in the whole table with no way to check for valid data. If this scares you (it does me), set the form's AllowEdits property to False and Access will hide the Replace tab.
 

Users who are viewing this thread

Top Bottom