Search only current using DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

V

Vic Spainhower

Hello,

I am trying to do a search on a specific field on a form. The user selects
the field they want to search from a drop-down and I set the focus to the
field and then I do "DoCmd.DoMenuItem acFormBar, acEditMenu, 10, ,
acMenuVer70". However, it trys to search all fields instead of only the
desired field which brings up an error on Find Next because the focus has
changed which prevents FindNext from working.

The DoCmd.FindRecord has the option acCurrent so is there a way to set the
option when using DoCmd.DoMenuItem?

Thanks,

Vic
 
A

Allen Browne

If you are doing this from a command button, then the button has focus when
you click it. The buttons is not attached to a field that can be searched.

Try setting control back to the field that had focus before the button was
clicked:
Screen.PreviousControl.SetFocus
Then add the Search line.

You will need error handling, e.g. there may not be any previous control.
 
V

Vic

Try setting control back to the field that had focus before the button was
clicked:
Screen.PreviousControl.SetFocus
Then add the Search line.

You will need error handling, e.g. there may not be any previous control.

I added support for the 2173 error to the form error event handling and
when I set focus to previous control I get an error. So I tried calling
a routine to explicitly set focus to the field I am trying to search on
and that doesn't work either. The only way I can do multiple searches
on the same field is to click into the field before pressing findnext.

This used to work and I don't know when or what made it stop working.

Appreciate any help received.

Vic
 

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