Find Record using VBA

  • Thread starter Thread starter Steven R via AccessMonster.com
  • Start date Start date
S

Steven R via AccessMonster.com

My users have a form that they regularly use the find record feature - every
time they go into the form for the first time and use this canned feature, it
defaults to:

Field: <CurrentField>
Find: All of Field

I want them to be able to right away search all the form number one, and also
"Any part of field" - is there some way with VBA I could attach a procedure
to a button ?
 
Boy are you lucky!
I solved just that problem the other day.
Here is my code:
Private Sub butFind_Click()
' Display customized Find and Replace window
DoCmd.GoToControl "Type" <===== has to be a searchable control
SendKeys "%l{DOWN}%ha%n"
RunCommand acCmdFind
End Sub

Check out VBA Help for the Sendkeys statement. It can be very useful in lots
of circumstances.

- Dorian
 
Dorian,
Thanks !
I thought I saw a more complicated way of doing it some time ago, but your's
looks like a great solution - some people frown on Send Keys, but I haven't
got to that point where I've seen the evils of Send Keys - I will implement
that code...
Thanks Again !
Steve

Boy are you lucky!
I solved just that problem the other day.
Here is my code:
Private Sub butFind_Click()
' Display customized Find and Replace window
DoCmd.GoToControl "Type" <===== has to be a searchable control
SendKeys "%l{DOWN}%ha%n"
RunCommand acCmdFind
End Sub

Check out VBA Help for the Sendkeys statement. It can be very useful in lots
of circumstances.

- Dorian
My users have a form that they regularly use the find record feature - every
time they go into the form for the first time and use this canned feature, it
[quoted text clipped - 6 lines]
"Any part of field" - is there some way with VBA I could attach a procedure
to a button ?
 
Back
Top