Access 2003 Macro FindRecord

C

cchick

I'm trying to use a macro, with the findrecord command, to locate a
record on a form.

I thought this would work, but I'm stuck.
I go to the control for the field I want to search
I open a dialog box form with an unbound text box for the
user to type in the search criteria
The dialog box has a button that says FIND
The Find button initiates the macro with the FindRecord
command.

But I can't figure out how to pass the information from the unbound
control on the dialog box to the Find What property of the FindRecord
command.

I tested by putting a value into the "Find What" section, but it would
only find the first occurrence, and no others. So I couldn't even get
that to work right.

I really just wanted to create an easier to use "find" box. It drives
me nuts that my users always have to select "Match Any Part of Field."
They always want to do that, and not "Whole Field."

Does this make sense? Do you have any suggestions? I guess I should
just learn VBA. :)

Cindy
 
S

Steve Schapel

Cindy,

A few comments...

1. It is less complicated if you had the search criteria textbox on the
same form as the data that you are searching. It is usual to put such
in the Header section of the form. Otherwise, your macro needs to
specifically make sure you are in the right place before the FindRecord
kicks in, which would possibly mean a SelectObject action, followed by a
GoToControl action. (You would also have to do the equivalent in VBA,
by the way :) ).

2. Yes, the FindRecord action only finds the first occurence of a
match. You can use another FindRecord to go to the next match, with the
right settings in the macro arguments. But in my experience, FindRecord
is normally used where there is only one match anyway, i.e. to set the
focus to *a specific record* in order to "do something" with that
record. Which leads me to...

3. I am therefore wondering whether you are using this for an
appropriate purpose. Is what you are really trying to achieve is for
the user to be presented with a set of all those records that match the
search criteria? If so, I would go about it differently.
 

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