accmdfind settings

J

Jeri

I've been struggling with this issue for a while, and have searched other
questions for a couple of hours now but haven't found an answer yet. It
should be fairly simple, but the solution eludes me. I hope someone can help.

I am using Access 2007 for scientific data entry.

I have a table of plant species that will eventually grow quite large. On a
form I have fields for the species code, the scientific name, common name,
and alias names. I have a button (btn_SpeciesSearch) that opens the find
dialog box without the "replace" tab. I would like to have the default set to
search all fields, any part of the field. I also want the match case to be
turned off.

I'm using this code
:
me.allowedits=false
docmd.gotocontrol "FloraSpeciesCode"
docmd.runcommand (accmdfind)
me.allowedits=true


I tried using this:
Docmd.findrecord InputBox("enter
text"),acanywhere,false,acsearchall,acall,true

This sort of worked, but I'd like to use the dialog box so they have the
option of searching particular fields. Also, if they are searching for a
genus, it might turn up on a number of records. So the dialog box works
better.

For example, here is one plant species:
FloraSpeciesCode - Pote frut
ScientificName - Potentilla fruticosa
CommonName - bush cinquefoil
Alias - shrubby cinquefoil

If someone is entering a plant name, but can only remember "frut", this
record will come up. Obviously if they entered cinquefoil, this record would
come up twice, but I don't care so much about that. They have the option of
searching under a particular field.

I looked at the customization options, but don't want it to always search
all fields, but only in this particular instance.

I use a lot of combo boxes elsewhere, but it doesn't seem like it will work
for this application.

If anyone has any suggestions, I'd deeply appreciate your help.

Jeri
 
L

Linq Adams via AccessMonster.com

Having read this several times, I'm still not sure exactly what you want as
the default, but I'll put out a couple things for you to consider.

To search any part of a field, goto

Tools - Options -Find/Replace

and in

Default Find/Replace Behavior

set it to "General Search."

You'll have to close Access then re-open it for this change to take effect.

The trick to having it search all fields is to not use lines like

docmd.gotocontrol "FloraSpeciesCode"

to set focus to a given field before running the search command. This code

Private Sub SearchButton_Click()
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFind
End Sub

will search ***whichever*** field the cursor was in immediately before
clicking on it.

This code

Private Sub SearchButton_Click()
DoCmd.RunCommand acCmdFind
End Sub

will search ***all*** fields.

Hope this helps!
 
J

Jeri

Thanks for the response, and sorry; I really tried to explain it clearly. I
want the search form to come up with:

Look In: frm_FloraSpecies
Match: any part of field
Search: all
Match case: no

In Access 2007 the option for find/replace is in Access Options. I don't
want to do that, as it will affect the entire database. Plus, that didn't
seem to work anyway (even after closing and re-opening the database).

And unless I include a setfocus code on a field, the form doesn't have the
focus. The "Look in" field doesn't work, and it can't find any records.

So I'm still stumped.

Jeri
 
L

Linq Adams via AccessMonster.com

Sorry, don't run 2007; it's so different in so many ways! Hopefully someone
who does will drop by and help.
 

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