command of a button

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
 
M

Mike Mueller

: 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
 
R

Rebecca S.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top