Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search button to search particular field

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB

Is it possible to create a search button that will just search on one field. (I know if you click in the required field and then click a normal search button it will do that but they don't want to do that)
This is the code created by the wizard
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

I thought maybe I could set the focus on the form so that when you click the button it automatically searches on that field but am not a coder and don't know how to go about it.
Can anyone help?
 
In your code change the line with "Screen.PreviousControl.SetFocus" by "nameofthefield.setfocus" and the focus will be set on the correct field before executing the search.

Regards,

Bitbuster
 
Thanks I've tried that but am getting compile error variable not defined when I try to execute it.
 
This means you didn't give the correct name of the field in the code. Check in the properties of the field for the correct name.

Regards,

Bitbusters
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top