Find button on a form

K

Kathy Webster

I have a command button on a form that runs this macro on it's on click
event:
Find Record
Action Arguments:
Find What: =[Forms]![frmMatterSearch]![txtSearchString]
Match: Any part of field
Match case: No
Search: All
Search as Formatted: Yes
Only Current field: No
Find First: No

It works fine EXCEPT it is not searching all, it is only searching DOWN from
its current position.
 
S

Steve Schapel

Kathy,

I have never seen this problem before. If you set the Find First
argument to Yes, as an experiment, does it then find the record which it
doesn't find now?

Is the macro being run from the frmMatterSearch form itself? If so, I
would try changing the Find What argument to simply:
=[txtSearchString]
 
M

missinglinq via AccessMonster.com

Why not try starting the Macro with GotoRecord with the arguement First?
 
S

Steve Schapel

Missing,

Yep, that might be a fudge. It won't help us understnad why the
existing macro doesn't work as expected though.
 
K

Kathy Webster

It's acutally being run from a main form, and it's searching the subform.
But the macro first sends key {tab} to take focus from the main form
to the subform before it does the search command.

Steve Schapel said:
Kathy,

I have never seen this problem before. If you set the Find First argument
to Yes, as an experiment, does it then find the record which it doesn't
find now?

Is the macro being run from the frmMatterSearch form itself? If so, I
would try changing the Find What argument to simply:
=[txtSearchString]

--
Steve Schapel, Microsoft Access MVP

Kathy said:
I have a command button on a form that runs this macro on it's on click
event:
Find Record
Action Arguments:
Find What: =[Forms]![frmMatterSearch]![txtSearchString]
Match: Any part of field
Match case: No
Search: All
Search as Formatted: Yes
Only Current field: No
Find First: No

It works fine EXCEPT it is not searching all, it is only searching DOWN
from its current position.
 
S

Steve Schapel

Kathy,

Do you mean SendKeys? I don't think this is a good idea. You should
use a GoToControl action instead, to set the focus to the subform control.

To repeat my earlier question: If you set the Find First argument to
Yes, as an experiment, does it then find the record which it doesn't
find now?

Did you also try my suggestion to change the Find What argument to simply:
=[txtSearchString]
 
K

Kathy Webster

Steve, Sorry it took me so long to respond.

Yes, as you suggested, I changed the Find First argument to Yes, and the
search starts from the beginning. However, when the Find First argument is
set to No, it is still only searching DOWN from the current location, even
though the Search argument is set to ALL.

I also tried changing the Find What argument to simply =[txtSearchString],
and it is still only searching DOWN from the current location, even though
the Search argument is set to ALL.

Helllllp!!
Kathy

Steve Schapel said:
Kathy,

I have never seen this problem before. If you set the Find First argument
to Yes, as an experiment, does it then find the record which it doesn't
find now?

Is the macro being run from the frmMatterSearch form itself? If so, I
would try changing the Find What argument to simply:
=[txtSearchString]

--
Steve Schapel, Microsoft Access MVP

Kathy said:
I have a command button on a form that runs this macro on it's on click
event:
Find Record
Action Arguments:
Find What: =[Forms]![frmMatterSearch]![txtSearchString]
Match: Any part of field
Match case: No
Search: All
Search as Formatted: Yes
Only Current field: No
Find First: No

It works fine EXCEPT it is not searching all, it is only searching DOWN
from its current position.
 
S

Steve Schapel

Kathy,

I am sorry, I don't know what the problem is here. I have never used
the FindFirst action in this way myself. I.e. in my experience it is
useful if there is *one* matching record that you are trying to locate.
I.e. it is more of a "find" than a "search". If it was mine, I would
start looking for an alternative approach to your needs. I haven't
really grasped what you are really trying to achieve here. But, for
example, if your purpose is to see all/any records that contain a search
crieteria term, then you can use a Filter (see ApplyFilter action, or
else SetValue related to the Filter and FilterOn properties of the
subform), or else set the query that the subform is based on accordingly
(see Requery action), or change the RecordSource property of the subform
(see SetValue action).
 
K

Kathy Webster

Steve: I did this. Thanks, it works. I hate using SendKeys, too, but I
didn't know another way.
Karen

Steve Schapel said:
Kathy,

Do you mean SendKeys? I don't think this is a good idea. You should use
a GoToControl action instead, to set the focus to the subform control.

To repeat my earlier question: If you set the Find First argument to Yes,
as an experiment, does it then find the record which it doesn't find now?

Did you also try my suggestion to change the Find What argument to simply:
=[txtSearchString]

--
Steve Schapel, Microsoft Access MVP

Kathy said:
It's acutally being run from a main form, and it's searching the subform.
But the macro first sends key {tab} to take focus from the main form
to the subform before it does the search command.
 

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