command of a button

  • Thread starter Thread starter Rebecca S.
  • Start date Start date
R

Rebecca S.

I have a button on a form that is a find record button.
What I want to happen when the button is clicked is for
it to search the lastname of a record. Right now what it
does is search what ever field the cursor is on when
someone clicks the button. How do I set it so it will
automatically search the lastname field when clicked?

Thanks in advance!
Rebecca
 
: I have a button on a form that is a find record button.
: What I want to happen when the button is clicked is for
: it to search the lastname of a record. Right now what it
: does is search what ever field the cursor is on when
: someone clicks the button. How do I set it so it will
: automatically search the lastname field when clicked?
:
: Thanks in advance!
: Rebecca

What you need to do is go into the code and set the focus on
the lastname field. The following example is code that I
use for searching by zip codes.
-Mike

Private Sub ZipFind_Click()
On Error GoTo Err_ZipFind_Click
Dim SZip As String

SZip = InputBox("Enter ZIP Code")
ZIP.Enabled = True
ZIP.SetFocus
DoCmd.FindRecord SZip, acStart

Text12.SetFocus

Exit_ZipFind_Click:
Exit Sub

Err_ZipFind_Click:
MsgBox Err.Description
Resume Exit_ZipFind_Click

End Sub
 
What you need to do is go into the code and set the
focus on
the lastname field. The following example is code that I
use for searching by zip codes.
-Mike

Private Sub ZipFind_Click()
On Error GoTo Err_ZipFind_Click
Dim SZip As String

SZip = InputBox("Enter ZIP Code")
ZIP.Enabled = True
ZIP.SetFocus
DoCmd.FindRecord SZip, acStart

Text12.SetFocus

Exit_ZipFind_Click:
Exit Sub

Err_ZipFind_Click:
MsgBox Err.Description
Resume Exit_ZipFind_Click

End Sub

Is that the only way to do it!?! That is a bit over my
head I think. Im not even sure what I would replace in
your example to the field name I need it to use.
Thank you for your time.. I am going to try to see if I
can figure it out using your example. Just not sure where
to start! HA!

Rebecca
 
Back
Top