On Closing a PopUp to Set Focus in OpenForm?

mlr

Registered User.
Local time
Today, 23:06
Joined
Feb 26, 2011
Messages
16
Hi, Hope someone can help…

I have a form to add new Accounts, one of the fields is a Combo Box listing Street Names for a specific area, if a street name doesn’t exist I have a command button calling a Pop Up Form to enter the new Street Name, coping the area code from the New Account Form, up to here it works…

But on closing the Pop Up Form I want the focus to move back to the Street Name Combo Box in New Account Form so that the newly created Street Name can be selected, how do I do this?

Kind Regards
Mark
---------------------------------------------
MS Office 2010 Pro, Windows 7 SP1 32bit
 
I think placing this in the Form_Activate event of the New Account Form will do the job. You'll also need to requiry the combobox:

Code:
Private Sub Form_Activate()
  Me.StreetNameCombo.Requery
  Me.StreetNameCombo.SetFocus
End Sub
Now this will set the focus on the combobox when the New Account Form first opens, as well.

If that doesn't suit you, behind your command button, you can open the Street Name Form using the code

Code:
DoCmd.OpenForm "StreetNameForm", , , , , acDialog
Me.StreetNameCombo.Requery
Me.StreetNameCombo.SetFocus
The acDialog parameter means that the Street Name Form opens with the Modal Property set to Yes, which means that the code in the first form stops executing until the Popup form is closed.

You'll need to use your exact names, of course, and incorporate your code for copying the proper area code.

Linq ;0)>
 
Last edited:
Sorry, maybe I was a vague on what I wanted…

On clicking the ‘Add Street’ button, it opens the PopUp Form, then clicking on he PopUp Form Update Button it will close the PopUp & move back New Account Form - here I want it to set focus on Physical Street Name Combo Field.

Thanks
 

Attachments

  • MSAq001.jpg
    MSAq001.jpg
    62.5 KB · Views: 281
Try;
Code:
Forms!YourFormNameHere!YourComboNameHere.SetFocus
This link has the correct syntax for referring to forms, sub-forms and there controls from various relative locations bookmark it for future reference.
 
On clicking the ‘Add Street’ button, it opens the PopUp Form, then clicking on he PopUp Form Update Button it will close the PopUp & move back New Account Form - here I want it to set focus on Physical Street Name Combo Field.
Well, I gave you two different methods fordoing that very thing!

Glad you got it working, at any rate!
 

Users who are viewing this thread

Back
Top Bottom