J
Joel Wiseheart
I am trying to use a custom spell check function, that
will spell check ALL DATA ENTRY FIELDS on a particular
form, instead of checking each field one at a time.
I couldn't use the built in spell checker, because in a
data entry form, it doesn't stop at the end of a record.
It forwards the form to the next record, and continues
checking.
This function works great, with one exception: When
the "SetFocus" command forwards the focus from field to
field, all of the other associated events trigger as well
(Enter, Before Update, After Update, etc.). I have other
data validation code in those events.
Is there any way to make it so the other events don't
run? The built-in spell checker doesn't seem to do this.
Here's the code. Thanks!
------------------------------------------------------
Public Function SpellCheck() As Boolean
'Purpose: Spell check all data entry fields on a form.
On Error GoTo Error_SpellCheck
Dim frm As Form
Dim ctl As Control
SpellCheck = False
Set frm = Screen.ActiveForm
For Each ctl In frm.Controls
If TypeOf ctl Is TextBox Or _
TypeOf ctl Is ComboBox Then
If ctl.Enabled = True And _
ctl.Visible = True Then
If Len(ctl) > 0 Then
DoCmd.SetWarnings False
With ctl
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End If
End If
End If
Next ctl
MsgBox "The spell check is complete.",
vbInformation, "Completed"
SpellCheck = True
Exit_SpellCheck:
Exit Function
Error_SpellCheck:
Call ErrorHandlerCustom("mdlMRRButton", "SpellCheck")
Resume Exit_SpellCheck
End Function
will spell check ALL DATA ENTRY FIELDS on a particular
form, instead of checking each field one at a time.
I couldn't use the built in spell checker, because in a
data entry form, it doesn't stop at the end of a record.
It forwards the form to the next record, and continues
checking.
This function works great, with one exception: When
the "SetFocus" command forwards the focus from field to
field, all of the other associated events trigger as well
(Enter, Before Update, After Update, etc.). I have other
data validation code in those events.
Is there any way to make it so the other events don't
run? The built-in spell checker doesn't seem to do this.
Here's the code. Thanks!
------------------------------------------------------
Public Function SpellCheck() As Boolean
'Purpose: Spell check all data entry fields on a form.
On Error GoTo Error_SpellCheck
Dim frm As Form
Dim ctl As Control
SpellCheck = False
Set frm = Screen.ActiveForm
For Each ctl In frm.Controls
If TypeOf ctl Is TextBox Or _
TypeOf ctl Is ComboBox Then
If ctl.Enabled = True And _
ctl.Visible = True Then
If Len(ctl) > 0 Then
DoCmd.SetWarnings False
With ctl
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End If
End If
End If
Next ctl
MsgBox "The spell check is complete.",
vbInformation, "Completed"
SpellCheck = True
Exit_SpellCheck:
Exit Function
Error_SpellCheck:
Call ErrorHandlerCustom("mdlMRRButton", "SpellCheck")
Resume Exit_SpellCheck
End Function