Change the Look In field of the find dialog in Visual Basic

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to open the Find menu command from a button on a form. Normally
when the user goes to find using the menu the 'Look In' field of the dialog
box gives two choices. One is the actually control that is the focus the
other is the entire form. When I use my code it only shows one choice, which
is the control that I set the focus to. How do I set the Look In field to
either the entire form or have the two choices of either the form or the
control that has focus?
The code is below for the button:

Private Sub Search_Click()
Forms!CaseFilesv1.SetFocus
RunCommand acCmdFind
End Sub
 
Omit the SetFocus line.

If the command button has focus when you activate the search, the Look In
will not be set.

You cannot use that dialog to specify 2 fields to search.
 
If I don't include the SetFocus line it disables the "Look In" Field
altogether and if I try to do a search it brings up a dialog box that says:

"You can't use Find or Replace now."

Then gives me some information on why this could possibly be the problem.
So I wanted to get it to SetFocus to the entire form but I don't know how.
 
Yes, the Look In field will be disabled, and so the search will be in all
the fields of your form, which I think was what you wanted to achieve.

If you cannot use Find/Replace, it could be because your form is unbound.
 
I am trying to search the form but when I omit that SetFocus line it instead
tries to search the database itself, which generates the error message in my
previous post if I actually try to search for something. The entire form is
bound directly to its corresponding tables. Is there no way to specify a
form as the focus?
 
Dedren, the terms you are using make it impossible to answer your question.

If you have several forms open, you set focus to a particular form (i.e.
make it the active form), but that does not mean that the form itself has
focus instead of one of its controls. The concept of a form having focus in
that sense is a nonsense.

The meaning of "... tries to search the entire database" also eludes me. You
are a form that is trying to search dozens (or hundreds) of tables that
might exist in your mdb file (database)?

"The entire form is bound directly to its corresponding tables" means ??? A
bound form has *one* recordsource. That will be a table, or possibly a
multi-table query or SQL statement.

Sorry: I cannot answer a question I don't understand.
 
Dedren said:
Is there any way I could send you the DB?

Why? You just need to rephrase your query in a way that Allen & the
rest of us can understand. It's you job to make it clear - not his job
to guess what you mean, by looking at your database :-)

Try to tell us the following:

1. Exactly what you /did/ (in "end user" terms);
2. Exactly what did you thought /should happen/, and
3. Exactly what /did happen/.

Then someone can probably answer you.

Try to avoid descriptions like: "it tries to search the database
itself". No-one is sure what you mean by "it", or "the database
itself", in that sentence. If you mean "the form", say "the form". If a
search returns the wrong records, say "the search returns the wrong
records", and so on.

HTH,
TC
 
That is the best piece of advice I have gotten in a very long time. I had
written a more lengthly thank you before but when I tried to post it I was
logged out from inactivity so it was lost. Currently I am working on a
different approach to letting the user search through the database but this
will help me become clearer if I have any other questions. I just had to
write back to show my appreciation for you taking the time to tell me this.

Again thank you.
 

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

Back
Top