Search Command Button Question

BriPriUK

New member
Local time
Today, 03:03
Joined
Jan 20, 2009
Messages
2
Hi All
I've set up a 'Search' command button on a form using the wizard, which works.
What I would like to do is have it open the dialog box with 'Match' set to 'Part of Field' as default, instead of 'Whole Field'. Is this possible?
The Event Procedure code that the wizard uses is

Option Compare Database

Private Sub Print_Click()
On Error GoTo Err_Print_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click

End Sub
Private Sub Search_Click()
On Error GoTo Err_Search_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Search_Click:
Exit Sub

Err_Search_Click:
MsgBox Err.Description
Resume Exit_Search_Click

End Sub

Brian
 
Choose Options from the Tools menu. On the Edit/Find tab, set Default Find/Replace behavior to General Search.

You can set this programmatically with:

Application.SetOption "Default Find/Replace Behavior",1

These methods require setting the behavior, then closing Access, then re-opening it, but it'll stay set that way until you change it again, for all apps run under that version of Access.

OR you can use this method to change it when clicking on your search button:
Code:
Private Sub FindIt_Click()
  Screen.PreviousControl.SetFocus
  SendKeys "%ha%n", False
  DoCmd.RunCommand acCmdFind
End Sub

Just note that the use of SendKeys can cause problems under some versions/service packs of Access. I only use it when absolutely nothing else will do what I need done, but I've never personally never had a problem.
 
Many Thanks
The Tools option is just what I need, but I'll keep the other tips for reference.
This is a great forum - thanks again.
Brian
 

Users who are viewing this thread

Back
Top Bottom