Link to home
Start Free TrialLog in
Avatar of Harry Batt
Harry Batt

asked on

Set focus on form

I have a form that opens by clicking on a command button on a modal form.  When the new form opens, it is hidden behind the previously opened form.  I want to keep the previously opened form visible but want the new form to appear in front of it.  How do I accomplish this?  I have tried to set its focus on open, but that doesn't work.  Any ideas experts?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Set the Modal and Popup properties of the Form you are opening to Yes.

mx
OR ... you can just set the PopUp property of the form you are opening to Yes.  It will then initially open on Top of the other form, but can go behind if you click onto the original Form.

So, you have a couple of options ...

mx
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Harry Batt
Harry Batt

ASKER

DatabaseMX,

Thanks for your two options.  Here is the code I am using for opening the second form.  What I didn't mention is that there is another parent form that always remains open.  So in fact there are three forms open.  What I have done is change the second form's property so that modal=false and visible=false.  This is changed back to true when the third form is closed.

I haven't tried your solutions yet but will in a few minutes.
Private Sub cmdAddSolicitor_Click()
On Error GoTo cmdAddSolicitor_Click_Err

    DoCmd.OpenForm "frmSolicitorAdd-Gifts", acNormal, "", "", , acNormal
    Me.Modal = False
    Me.Visible = False
    
cmdAddSolicitor_Click_Exit:
    Exit Sub

cmdAddSolicitor_Click_Err:
    MsgBox Error$
    Resume cmdAddSolicitor_Click_Exit

End Sub

Open in new window

Setting the Pop Up property on the third form to yes solves the problem. Thanks again DatabaseMX.