Search argument for DoCmd.FindRecord

L

Luke

Hello -

I have a form with a combo box linked to a table of ID
numbers and a button next to it that I would like be able
to click to search on the selected item.

The combo box name is 'SearchField'
The field to be searched within the table
is 'FinishedGoodID'

NOTE THAT:

FinishedGoodID.SetFocus
DoCmd.FindRecord "12332", acEntire, False, acSearchAll,
False, acAll, True

WORKS!!!! It finds and displays my "12332" record on the
form just fine when the button is clicked.

BUT ...

FinishedGoodID.SetFocus
DoCmd.FindRecord Me!SearchField, acEntire, False,
acSearchAll, False, acAll, True

DOES NOT WORK! And - I have been able to verify that Me!
SearchField is holding the correct value (verified by
using an If-then-beep statement and an Open #1...Print
#1,Me!SearchField...Close #1 series). I also can't get the
statment to work with a var like x$, and I was able to
verify that x$ was also holding the correct string.

What is wrong with Me!SearchField in the DoCmd.FindRecord
statement? It acts like with anything other than a hard
string (e.g., "12332") for that argument it is looking for
a null string.

Thanks for any help,

Luke
 
L

Luke

Nevermind ...

I got it!

I had to change acAll to acCurrent to get it to work. Not
sure exactly why ... you would think that all of the
fields could be searched with the string, but I guess not.

The correct line is:

DoCmd.FindRecord Me!SearchField, acEntire, False,
acSearchAll, False, acCurrent, True

Luke
 

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