Searchforrecord does not appear to work

S

Spencer

I am unable to make the SearchForRecord action work in a macro. I
can't make the simplest test case work.
I set up a test database, one table with an ID and Description field.
I entered several rows of text in the Description field including one
that says Beverages.

Then I saved one macro, Search.

The macro where clause is copied directly from the help file.

object type: Table
Object name: Test Table
Record: First
Where Condition: Description = "Beverages"

It does not find the row with "Beverages". It appears to toggle
between other rows on repeated Runs.

I know FindRecord will work, but I want to use SearchForRecord so I
can specify the value of a form text box in the where condition. The
fixed literal is a test case that should work.

Any suggestions.
 
K

KARL DEWEY

Do not use Condition as you did -- Where Condition: Description = "Beverages"

Do this --
Find What = "Beverages"
 
K

KARL DEWEY

I did not read the whole post.

You can use an expression for what you want to find --
=[Forms]![YourForm]![TextBox]
 
S

Spencer

I did not read the whole post.

You can use an expression for what you want to find --
   =[Forms]![YourForm]![TextBox]

I understand the expression is supposed to permit me to us the
content of the text box. That is why I elected to use the
SearchForRecord action. The FindRecord action does not permit the
expression in a macro (it does in VBA). Don't forget, this is a macro,
not VBA code.

However, the expression did not work as advertized. So, in the spirit
of build a little, test a little, I tried a simpler case; seach for a
literal as shown in the help file. (They show the expression example
Karl shows, too.) I can't make the simple search for a literal work
either. Clearly, the function doesn't work or I am implementing it
incorrectly. I am seeking assistance on the correct implementation or
an explanation for the correct way to use the SearchForRecord action
if the Help instructions are incomplete.
 
K

KARL DEWEY

The FindRecord action does not permit the expression in a macro (it does in
VBA).
According to the explaination of the 'Action Arguments' in my 2007 it
accepts expressions. It has worked for me in the past.

Is it possible that your field is a 'Lookup' field?

--
Build a little, test a little.


Spencer said:
I did not read the whole post.

You can use an expression for what you want to find --
=[Forms]![YourForm]![TextBox]

I understand the expression is supposed to permit me to us the
content of the text box. That is why I elected to use the
SearchForRecord action. The FindRecord action does not permit the
expression in a macro (it does in VBA). Don't forget, this is a macro,
not VBA code.

However, the expression did not work as advertized. So, in the spirit
of build a little, test a little, I tried a simpler case; seach for a
literal as shown in the help file. (They show the expression example
Karl shows, too.) I can't make the simple search for a literal work
either. Clearly, the function doesn't work or I am implementing it
incorrectly. I am seeking assistance on the correct implementation or
an explanation for the correct way to use the SearchForRecord action
if the Help instructions are incomplete.
.
 

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