GoToControl Macro

G

GOL

Please read slowly to understand...

I have a main form with a command button you hit that pops up another form.
On this pop up form are search options. I have another command button on
this pop up form that when clicked runs the search. The macro on the command
button (on pop up form) needs to move the focus to the control I am searching
on the main form and then the FindRecord command is run to search for
whatever was typed in the text box of the pop up form.

**Problem** The GoToControl macro only puts the focus on the current
form/datasheet/etc. I need the focus to go to a totally different form (the
main form). I had to make a pop up form because there are too many search
options. Any suggestions?
 
K

Ken Snell [MVP]

Are you calling the popup form to be a "dialog" mode form? Do you close /
hide the popup form when you click the button on it?
 
G

GOL

The pop up form is in Dialog mode. I do wish to close it when the search has
been completed.
 
K

Ken Snell [MVP]

When a form is in Dialog mode, you cannot click on or move the focus to any
other object until that form is hidden or closed.

Make this the first line of code in the popup form's command button's Click
event:
Me.Visible = False

Then make this the last line of code in the popup form's command button's
Click event:
DoCmd.Close acForm, Me.Name, acSaveNo

When you make the form invisible, the focus returns to the previous form.
You now can set focus where you want, etc.

--

Ken Snell
<MS ACCESS MVP>
 
K

Ken Snell [MVP]

I just remembered that you're using a macro, not VBA code. So the first step
would be a SetValue action (to set the form's Visibility property to No),
and the last step would be a Close action (to close the popup form).

--

Ken Snell
<MS ACCESS MVP>
 
Top