Karen Schaefer
asked on
Determine which form called the report - so I can reopen on close of report
Looking for code to determine which form called the report - so I can reopen on close of report.
What is the proper syntax I have two different forms that can call the report? I need to return to that form on close of the active report..
Forms names are FE_ITPR and FE_ITPR_Enovia.
The current code is asking the user if they wish to return to the previous form or back to the Main Menu. This is why I need to determine which form was the last active.
Thanks,
k
What is the proper syntax I have two different forms that can call the report? I need to return to that form on close of the active report..
Forms names are FE_ITPR and FE_ITPR_Enovia.
The current code is asking the user if they wish to return to the previous form or back to the Main Menu. This is why I need to determine which form was the last active.
Thanks,
k
Private Sub Report_Close()
Dim frm As Form
DoCmd.Minimize
Select Case MsgBox("Click Yes if you wish to return to previous form." _
& vbCrLf & "" _
& vbCrLf & "Click No, to return to Main Menu." _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "What do you want to do?")
Case vbYes
If Forms![FE_ITPR_Enovia]![ITPR Detail].Form.Visible = True Then
frm = Me.Parent.active
If frm.Visible = False Then
frm.Visible = True
End If
Else
If Forms!FE_ITPR.Visible = False Then
Forms!FE_ITPR.Visible = True
End If
End If
Case vbNo
If Forms!FS_MSB.Visible = False Then
Forms!FS_MSB.Visible = True
DoCmd.Close acForm, "FE_ITPR", acSaveYes
End If
End Select
DoCmd.Restore
End Sub
ASKER
how do I modify the code to inlcude the form name?
DoCmd.OpenReport "R_ITPR_Release", acViewPreview, "", "", acNormal,
DoCmd.OpenReport "R_ITPR_Release", acViewPreview, "", "", acNormal,
ASKER
DoCmd.OpenForm Forms(OpenArgs), acNormal, , , acFormEdit
I am getting wrong data type error.
I am getting wrong data type error.
ASKER
here is what I have so far
I tried setting a variable to pass the form name - without success.
also
DoCmd.Close acForm, Forms(OpenArgs), acSaveYes
Was not successful - did not like the syntax.
any Ideas?
K
I tried setting a variable to pass the form name - without success.
also
DoCmd.Close acForm, Forms(OpenArgs), acSaveYes
Was not successful - did not like the syntax.
any Ideas?
K
Private Sub Report_Close()
Dim nFrm As Form
DoCmd.Minimize
Set nFrm = Forms(OpenArgs)
Debug.Print nFrm
Select Case MsgBox("Click Yes if you wish to return to previous form." _
& vbCrLf & "" _
& vbCrLf & "Click No, to return to Main Menu." _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "What do you want to do?")
Case vbYes
Forms(OpenArgs).Visible = True
Case vbNo
If Forms!FS_MSB.Visible = False Then
Forms!FS_MSB.Visible = True
DoCmd.Close acForm, Forms(OpenArgs), acSaveYes
End If
End Select
DoCmd.Restore
End Sub
ASKER
how do I close using the OpenArgs - what is the proper syntax?
K
K
open the report with this
DoCmd.OpenReport "R_ITPR_Release", AcView:=acViewPreview, OpenArgs:=Me.Name
Private Sub Report_Close()
Select Case MsgBox("Click Yes if you wish to return to previous form." _
& vbCrLf & "" _
& vbCrLf & "Click No, to return to Main Menu." _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "What do you want to do?")
Case vbYes
Forms(me.OpenArgs).Visible = True
Case vbNo
End Select
DoCmd.Restore
End Sub
DoCmd.OpenReport "R_ITPR_Release", AcView:=acViewPreview, OpenArgs:=Me.Name
Private Sub Report_Close()
Select Case MsgBox("Click Yes if you wish to return to previous form." _
& vbCrLf & "" _
& vbCrLf & "Click No, to return to Main Menu." _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "What do you want to do?")
Case vbYes
Forms(me.OpenArgs).Visible
Case vbNo
End Select
DoCmd.Restore
End Sub
ASKER
Thanks, how do I close using the OpenArgs - what is the proper syntax? on the case vbNo
Case vbNo
If IsFormLoaded(Forms(OpenArg s)) = True Then
DoCmd.Close
End If
If IsFormLoaded(Forms!FS_MSB) = True Then
Forms!FS_MSB.Visible = True
' DoCmd.Close acForm, nrm, acSaveYes
End If
End Select
DoCmd.Restore
End Sub
K
Case vbNo
If IsFormLoaded(Forms(OpenArg
DoCmd.Close
End If
If IsFormLoaded(Forms!FS_MSB)
Forms!FS_MSB.Visible = True
' DoCmd.Close acForm, nrm, acSaveYes
End If
End Select
DoCmd.Restore
End Sub
K
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks that did the trick.
Karen
Karen
DoCmd.OpenReport "Yourreport", , , , , "YourForm"
Then, when you close the report, just reference the openargs property again when the form is closed:-
docmd.openform Forms(OpenArgs)
And that should pretty much do the trick.
Matt