Search a field

R

RitchieJHicks

Hi,

I'd like to have a small button next to specific fields in my form, which
when clicked, will allow the user to search all records relating to that
field. In my case my serached vehicle will be Vehicle Regstration, Surname,
Reference and Accident Date.

Is there an easy way to do this?

Regards,
Ritchie.
 
G

Golfinray

Put a command button on the form. When you start command button it will run a
wizard for the setup. Tell it you want a search function. After the search
button is ready, run it and set up the search procedure you want.
 
A

Allen Browne

If you just want to filter the form to the records that have the same value,
use the Filter By Selection button on the toobar.

If you want to offer the user the opportunity to filter by a combination of
fields, this example shows how it's done:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

Alternatively, if you only need them to search on one field at a time (but
be able to choose which one), this one is simpler for you to set up:
Find as you type - Filter forms with each keystroke
at:
http://allenbrowne.com/AppFindAsUType.html
 
R

RitchieJHicks

The wizard doesn't have the search function listed.

Are you using a newer version of Access 2003 by any chance?
 
R

RitchieJHicks

Hi Allen,

I don't think I was clear in my question. I don't need a complicated search
function, just one like that brings up the find box (like when pressing
CTRL+F from within the form). I'd like users to be able to click a button to
bring up the Find box relevent to the field, as apposed to using the keyboard
shortcut.

Regards,
Ritchie.
 
A

Allen Browne

What's wrong with the Binoculars icon on the toolbar?

You can add a button that does a:
RunCommand acCmdFind

But first you would need to SetFocus to Screen.PreviousControl, using error
handling in case that can't happen.
 
R

RitchieJHicks

Hi Allen,

Thanks for getting back to me. My final db will not have the toolbar as I
plan to remove anything which may give a user easy access to accidently break
it.

As I am not very clear on coding, could you elaborate, please?

Regards,
Ritchie
 
A

Allen Browne

1. Set the On Click property of your command button to:
[Event Procedure]

2. Click the Build button (...) beside this.
Access opens the code window.

3. Add the lines:
Screen.PreviousControl.SetFocus
RunCommand acCmdFind

4. Add error handling to the routine, in case there is no previous control.
If you don't know about error handling, here's a starting point:
http://allenbrowne.com/ser-23a.html
 

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