closing form recalls form opened from

Gr3g0ry

Registered User.
Local time
Today, 06:47
Joined
Oct 12, 2017
Messages
163
i have a number of pop up forms. i now realize that i can have three or more of these forms open. id like to be able to just open one format a time and when i close that form, i want to return to the form it was called from.

ive been looking at code in the repository but im more confused now.

any suggestions ?
 
on the Calling form, add an OpenArgs parameter to open the PopUp form
passing it's Name:

DoCmd.OpenForm FormName:="PopUpFormName", OpenArgs:=Me.Name

when its time to close the PopUp form, add code to it's
Unload Event to Setfocus to the Calling Form:


Private Form_Unload(Cancel As Integer)
If Me.OpenArgs <> "" Then Forms(Me.OpenArgs).SetFocus
End If
 
Hey man, thanks for the help.there is a hitch though,

on the Calling form, add an OpenArgs parameter to open the PopUp form
passing it's Name:

DoCmd.OpenForm FormName:="PopUpFormName", OpenArgs:=Me.Name


i havent figured out where to do this ?do i attach it to the button that calls the new form in the onClick event ?

im calling the new form from a button by the way
 
Yes put it there
 
ok im sorry. i said this initially ..

.... i have a number of pop up forms. i now realize that i can have three or more of these forms open. id like to be able to just open one format a time and when i close that form, i want to return to the form it was called from....

to be more specific.

when i call a new form, i want to close the calling form, leaving only the called/new form open. and when closed, the original form that id the calling reopens. Automatically. something like a history.back() fucntion.
 
I did not get that, meaning reopen the calling form on same record on table before it closed.
 
no. i have a form with buttons that open pop up forms. Something like a menu form. this "menu form" opens a form that adds/edit/delete records. when the form to add/edit/delete records is called, id like to close the menu form and only have the called form open. on close of the called form, i like to return to the form that did the calling originally.

no data transfers.
 
so, this is what you have:
1. Form
2. Menu form
3. Add/edit/delete form

Goal:
when No.3 closes, return to No.1

on calling No.2 from No.1 use my code earlier on the button:

DoCmd.OpenForm FormName:="PopUp menu", OpenArgs:=Me.Name

on Calling No.3 from No.2, pass the OpenArgs to No.3, like a daisychain:


DoCmd.OpenForm FormName:="the add/edit/form", OpenArgs:=Me.OpenArgs


on closing the "add/edit/form", do the other code i gave on Unload event:

Private Sub Form_Unload()
If Me.OpenArgs <> "" Then Forms(Me.OpenArgs).SetFocus
End Sub
 
Hi Pat,

How would you do it if the calling form is from a button on a subform of a main form?
 
thanks all. ive been working on other aspects of my project hence my inactivity. now im back at this issue. will let u know how it goes
 

Users who are viewing this thread

Back
Top Bottom