Option Compare Database
Option Explicit
Public Sub CommonClose(frm As Form)
On Error GoTo ErrProc
If bForceClose = True Then
Exit Sub 'do not run close code
End If
If frm.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
If IsNull(frm.OpenArgs) Then
DoCmd.OpenForm "Switchboard"
Else
DoCmd.OpenForm frm.OpenArgs
End If
bForceClose = False 'reset variable
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 2102 'bad open args form name
Resume ExitProc
Case 2455 'happens for A2007 when unbound form references the Dirty property
Resume Next
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub
Public Sub CommonReturn(frm As Form)
On Error GoTo ErrProc
If frm.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
DoCmd.Close acForm, frm.Name
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 3709, 3021, 2501 'caused when save is cancelled
Resume ExitProc
Case 2455 'happens for A2007 when unbound form references the Dirty property
Resume Next
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub
Public Sub CommonSave(frm As Form)
On Error GoTo ErrProc
If frm.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 3709, 3021, 2501, 3071 'caused when save is cancelled
Resume ExitProc
Case 2455 'happens for A2007 when unbound form references the Dirty property
Resume Next
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
Resume Next
End Select
End Sub
Public Sub CommonOpen(frm As Form)
On Error GoTo ErrProc
If Forms!frmLogin!txtBELocation = "Production" Then
frm.txtBELocation.Visible = False
Else
frm.txtBELocation.Visible = True
frm.txtBELocation = Forms!frmLogin!txtBELocation
End If
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 2450 'trap some but that happens when app closes
Resume ExitProc
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
End Select
End Sub
Public Sub CommonExit(frm As Form)
On Error GoTo ErrProc
If frm.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
DoCmd.Close acForm, frm.Name, acSaveNo
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 3709, 3021, 2501, 3071 'caused when save is cancelled
Resume ExitProc
Case 2455 'happens for A2007 when unbound form references the Dirty property
Resume Next
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
Resume Next
End Select
End Sub