Mike Rudolph
asked on
How to use TempVars to open a form?
Dear Experts,
I currently have a button that opens a form using an embedded macro.
I have two forms nearly identical one called frmStudent and frmStudentShort. The 'short' version is a continuous form that displays less information that the original 'frmStudent' form. Anyway, I have several buttons on the frmStudent form that open various popup forms. When the associated popup forms close I either requery the frmStudent or open the frmStudent form again. The problem I am having is now that I have 'copied' the frmStudentShort form all the associated popup forms either requery or open frmStudent which causes an error 'cause the frmStudentShort form is open and not the frmStudent.
That said, I would like to use tempVars and pass the form name in the macro so when I close the associate popup form I can use the tempVars in the command.
Instead something like:
Of course the above code does not work so need some help with this. Alos, how would I open/close a form using TempVars....
DoCmd.Close acForm, "frmStudent" ???
DoCmd.OpenForm "frmStudent" ???
Thanks!
I currently have a button that opens a form using an embedded macro.
I have two forms nearly identical one called frmStudent and frmStudentShort. The 'short' version is a continuous form that displays less information that the original 'frmStudent' form. Anyway, I have several buttons on the frmStudent form that open various popup forms. When the associated popup forms close I either requery the frmStudent or open the frmStudent form again. The problem I am having is now that I have 'copied' the frmStudentShort form all the associated popup forms either requery or open frmStudent which causes an error 'cause the frmStudentShort form is open and not the frmStudent.
That said, I would like to use tempVars and pass the form name in the macro so when I close the associate popup form I can use the tempVars in the command.
Private Sub cmdClose_Click()
DoCmd.Close acForm, "frmAssignGroups"
Forms!frmStudent.Requery
End Sub
Instead something like:
Private Sub cmdClose_Click()
DoCmd.Close acForm, "frmAssignGroups"
' Forms!frmStudent.Requery
Forms! & TempVars!FormName & .Requery
End Sub
Of course the above code does not work so need some help with this. Alos, how would I open/close a form using TempVars....
DoCmd.Close acForm, "frmStudent" ???
DoCmd.OpenForm "frmStudent" ???
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All,
So I figured it out. Here is the code when I leave the form:
Here is the code when I return to the form:
So I figured it out. Here is the code when I leave the form:
Dim ReturnForm As TempVars
TempVars.Add "ReturnForm", "frmStudentShort"
Here is the code when I return to the form:
DoCmd.OpenForm TempVars!ReturnForm, , , "ClassID = " & Me.ClassID
ASKER