Option Compare Database
Option Explicit
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
Public Sub cmdSpell_EntireRecordset()
''' doesn't seem to do anything when called from Before update event of form
On Error GoTo Err_Proc
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
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_EntireRecordset of Module mSpellCheckForRuntime"
End Select
End Sub
''''''Public Sub cmdSpell_Click()
'''''' Dim ctlSpell As Control
''''''
'''''' On Error GoTo Err_Proc
''''''
'''''' Set ctlSpell = Screen.PreviousControl
'''''' If TypeOf ctlSpell Is TextBox Then
'''''' If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
'''''' 'MsgBox "There is nothing to spell check."
'''''' 'ctlSpell.SetFocus
'''''' Exit Sub
'''''' End If
'''''' With ctlSpell
'''''' .SetFocus
'''''' .SelStart = 0
'''''' .SelLength = Len(ctlSpell)
'''''' End With
'''''' DoCmd.RunCommand acCmdSpelling
'''''' Else
'''''' MsgBox "Spell check is not available for this item."
'''''' End If
'''''' 'ctlSpell.SetFocus
''''''
''''''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_Click of Module mSpellCheckForRuntime"
'''''' End Select
'''''' End Sub
''''''
Public Function SpellChecker(Calling As Form)
Dim ctlSpell As Control
DoCmd.RunMacro "mWarningsOff"
Set ctlSpell = Calling.ActiveControl
If (ctlSpell.Locked) Then
''Ignore
Else
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
DoCmd.RunMacro "mWarningsOn"
End Function