Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Find Isn't Available

Status
Not open for further replies.

LincolnMarkV

Programmer
Dec 22, 2003
72
0
0
US
Hello all,

I have a form with a command button on it that is used to search the fields.

*************Code*************
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdFind

******************************

I keep getting an error message. "The command 'find' isn't available now". I am at a loss and know it must be something very simple.

Any advise would be greatly appreciated.

Thanks!!!
 
What is it that you are trying to accomplish? This is a bit vague. If you give a bit more description, we can probably help you out.
 
Sorry about the vagueness....

I have a form that is called from another form. When both of the forms are open, the modal form gives me an error when clicking my find button. It is the same button that the wizard creates on the forms. I have tried switching from modal on to off with no luck. I don't understand what is preventing the find command from being used when this form is open. When I open the form idependently, the find command works as normal.

 
Are you clicking on a text box of the form before clicking on the Find button? If not, there's no PreviousControl to set focus to or to use as the basis for the Find command. If you open the form indepentently, on the other hand, focus goes to the first control in the tab order, and thus the Find command will run properly.



The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I beleive that screen.previouscontrol will recognize the last control in the tab order property. Instead of using

Screen.PreviousControl.SetFocus

Try replacing it with

me.myControl.setfocus
Docmd.Runcommand accmdfind

where you are replacing myControl with the name of your actual control.

That will be certain that you are moving to the correct control that you want to use to find your data.

 
Thanks Kkit. That didn't work but I did get it figured out.

When the form was being opened by the command button, the form was being opened as AcDialog. This was disabling the find command.

Thanks for all of the suggestions.
 
That will certainly be good to know for the future. I hadn't thought of that! But of course! Makes sense.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top