planetdrouin
Technical User
I am trying to call a form from many different sources and return to the calling form. I am trying to use the openargs function but to no avail. My code is as follows:
Called form: frmClientOfficeIn
Calling form (this example): frmOutstandingCheques
(Code from Calling Form)
Private Sub Details_Click()
On Error GoTo Err_Details_Click
gstrWhereClient = "[InOutID] = " & Me!InOutID
DoCmd.OpenForm FormName:="frmClientOfficeIn", _
WhereCondition:=gstrWhereClient, _
OpenArgs:="frmOutstandingCheques"
Forms!frmClientOfficeIn.SetFocus
Forms!frmClientOfficeIn!AccountsMenu.Visible = False
Forms!frmClientOfficeIn!MainMenu.Visible = False
Forms!frmClientOfficeIn!CloseLedger.Visible = True
Exit_Details_Click:
Exit Sub
Err_Details_Click:
MsgBox "No information selected to view.", vbExclamation, "NDR Software 1.0"
Resume Exit_Details_Click
End Sub
(Code on Called Form)
Private Sub CloseLedger_Click()
DoCmd.Close acForm, Me.Name
Forms(Me.OpenArgs).SetFocus
End Sub
I get a run-time error that the expression you entered refers to an object that is closed or does not exist. If I replace the line:
Forms(Me.OpenArgs).SetFocus
With
Forms("frmOutstandingcheques".SetFocus
My code works. But I would rather use the openargs function as I will be calling the form from many different forms. Any help is greatly appreciated.
Lawrence
Called form: frmClientOfficeIn
Calling form (this example): frmOutstandingCheques
(Code from Calling Form)
Private Sub Details_Click()
On Error GoTo Err_Details_Click
gstrWhereClient = "[InOutID] = " & Me!InOutID
DoCmd.OpenForm FormName:="frmClientOfficeIn", _
WhereCondition:=gstrWhereClient, _
OpenArgs:="frmOutstandingCheques"
Forms!frmClientOfficeIn.SetFocus
Forms!frmClientOfficeIn!AccountsMenu.Visible = False
Forms!frmClientOfficeIn!MainMenu.Visible = False
Forms!frmClientOfficeIn!CloseLedger.Visible = True
Exit_Details_Click:
Exit Sub
Err_Details_Click:
MsgBox "No information selected to view.", vbExclamation, "NDR Software 1.0"
Resume Exit_Details_Click
End Sub
(Code on Called Form)
Private Sub CloseLedger_Click()
DoCmd.Close acForm, Me.Name
Forms(Me.OpenArgs).SetFocus
End Sub
I get a run-time error that the expression you entered refers to an object that is closed or does not exist. If I replace the line:
Forms(Me.OpenArgs).SetFocus
With
Forms("frmOutstandingcheques".SetFocus
My code works. But I would rather use the openargs function as I will be calling the form from many different forms. Any help is greatly appreciated.
Lawrence