Private Sub Form_BeforeUpdate(Cancel As Integer)
If Forms!frmLogin!chkOKPlanNotes = True Then
Else
MsgBox "You are not authorized to enter or change notes.", vbOKOnly
Me.Undo
Cancel = True
Exit Sub
End If
If Me.NewRecord = False Then
Select Case True
Case DateDiff("h", Me.ChangeDT, Now()) <= 24 And Forms!frmLogin!txtEmpID = Nz(Me.ChangeBy, Forms!frmLogin!txtEmpID)
'update allowed
Case Forms!frmLogin!chkISSPV = True
'update allowed
Case Else
MsgBox "Notes may only be changed by the person who made the entry (within 24 hours) or by a Supervisor.", vbOKOnly
Me.Undo
Cancel = True
Exit Sub
End Select
End If
If Not IsDate(Me.txtReferenceDT) Then
MsgBox "Reference date is required.", vbOKOnly
Me.txtReferenceDT.SetFocus
Cancel = True
Exit Sub
End If
If Me.cboNotesTypeID & "" = "" Then
MsgBox "Notes Type is required.", vbOKOnly
Me.cboNotesTypeID.SetFocus
Cancel = True
Exit Sub
End If
If Me.txtNoteText & "" = "" Then
MsgBox "Note text is required.", vbOKOnly
Me.txtNoteText.SetFocus
Cancel = True
Exit Sub
End If
If Me.cboEmpID & "" = "" Then
MsgBox "Taken By is required.", vbOKOnly
Me.cboEmpID.SetFocus
Cancel = True
Exit Sub
End If
Call cmdSpell_EntireForm(Me)
Me.ChangeBy = Forms!frmLogin!txtEmpID
Me.ChangeDT = Now()
End Sub
Public Sub cmdSpell_EntireForm(frm)
Dim ctlSpell As Control
Dim ctlName As String
On Error GoTo Err_Proc
DoCmd.SetWarnings False
' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
If ctlName = ctlSpell.name Then
GoTo Exit_Proc
Else
ctlName = ctlSpell.name
End If
End If
End If
Next
DoCmd.SetWarnings True
Exit_Proc:
On Error GoTo 0
Exit Sub
Err_Proc:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSpell_EntireForm of Module mSpellCheckForRuntime"
End Select
End Sub
Public Sub cmdSpell_SingleControl(cntl As Control)
Dim ctlSpell As Control
On Error GoTo Err_Proc
Set ctlSpell = cntl 'Screen.PreviousControl
If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
'MsgBox "There is nothing to spell check."
'ctlSpell.SetFocus
Exit Sub
End If
DoCmd.RunMacro "mWarningsOff" 'turn warnings off to surpress "complete" message
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
DoCmd.RunMacro "mWarningsOn"
Exit_Proc:
On Error GoTo 0
Exit Sub
Err_Proc:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSpell_SingleControl of Module mSpellCheckForRuntime"
End Select
End Sub