By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Form Focus for search

P: n/a
I've been up most of the night trying to get the basic searcg (find
record) facility to pre focus on a particular fielf so that it only
searches that field and returns the data for the whole form.
Here what i have been attempting to alter to set the focus just prior
to the search.

Private Sub Search_Payrollno_Click()
On Error GoTo Err_Search_Payrollno_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Search_Payrollno_Click:
Exit Sub

Err_Search_Payrollno_Click:
MsgBox Err.Description
Resume Exit_Search_Payrollno_Click
End Sub

but if I've clicked on any other field it uses that selected field
instead of the one I want to limit the user to searching in. All
offers most welcome.

Many Thanks
Nemesis
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just set the focus to the control you want to search on. Assuming you
want to set the focus on the control Payrollno you'd do this:

Me!Payrollno.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQIKzYechKqOuFEgEQJmjwCgp3ySlmc7V1agKeLnaesNy8 D45kIAoMnh
iY1NieJ+o96mTPkAdOZxwlUE
=f8AU
-----END PGP SIGNATURE-----
Nemesis wrote:
I've been up most of the night trying to get the basic searcg (find
record) facility to pre focus on a particular fielf so that it only
searches that field and returns the data for the whole form.
Here what i have been attempting to alter to set the focus just prior
to the search.

Private Sub Search_Payrollno_Click()
On Error GoTo Err_Search_Payrollno_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Search_Payrollno_Click:
Exit Sub

Err_Search_Payrollno_Click:
MsgBox Err.Description
Resume Exit_Search_Payrollno_Click
End Sub

but if I've clicked on any other field it uses that selected field
instead of the one I want to limit the user to searching in. All
offers most welcome.

Many Thanks
Nemesis


Nov 13 '05 #2

P: n/a
Many Thanks for your suggestion, but no joy. I added your lines but
now get the message object doesn't support
this property or method. Any ideas?

thanks

nemesis
MGFoster <me@privacy.com> wrote in message news:<8V******************@newsread1.news.pas.eart hlink.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just set the focus to the control you want to search on. Assuming you
want to set the focus on the control Payrollno you'd do this:

Me!Payrollno.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQIKzYechKqOuFEgEQJmjwCgp3ySlmc7V1agKeLnaesNy8 D45kIAoMnh
iY1NieJ+o96mTPkAdOZxwlUE
=f8AU
-----END PGP SIGNATURE-----
Nemesis wrote:
I've been up most of the night trying to get the basic searcg (find
record) facility to pre focus on a particular fielf so that it only
searches that field and returns the data for the whole form.
Here what i have been attempting to alter to set the focus just prior
to the search.

Private Sub Search_Payrollno_Click()
On Error GoTo Err_Search_Payrollno_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Search_Payrollno_Click:
Exit Sub

Err_Search_Payrollno_Click:
MsgBox Err.Description
Resume Exit_Search_Payrollno_Click
End Sub

but if I've clicked on any other field it uses that selected field
instead of the one I want to limit the user to searching in. All
offers most welcome.

Many Thanks
Nemesis

Nov 13 '05 #3

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there a control named "Payrollno" on the form that is running the VBA
code? To set the focus on a control using the Me! referent the code
must be on the form that holds the control.

If you have an Access version 97 (I believe) or higher you can use the
RunCommand method instead of the MenuItem method. E.g.:

Me!Payrollno.SetFocus
DoCmd.RunCommand acCmdFind

I tested this & it worked for me.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQRqoIechKqOuFEgEQIAcwCffKaRTXXzTOOxBFVWY3dZz0 HXL+YAoMwp
s8zrmMu1bWd2axjxtQ3g0sEK
=6Anc
-----END PGP SIGNATURE-----
Nemesis wrote:
Many Thanks for your suggestion, but no joy. I added your lines but
now get the message object doesn't support
this property or method. Any ideas?

thanks

nemesis
MGFoster <me@privacy.com> wrote in message news:<8V******************@newsread1.news.pas.eart hlink.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just set the focus to the control you want to search on. Assuming you
want to set the focus on the control Payrollno you'd do this:

Me!Payrollno.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQIKzYechKqOuFEgEQJmjwCgp3ySlmc7V1agKeLnaesNy8 D45kIAoMnh
iY1NieJ+o96mTPkAdOZxwlUE
=f8AU
-----END PGP SIGNATURE-----


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.