I am using this code to perform spell checks (not sure where I got it, but it works a peach):
Setup:
The textboxes that are spell checked reside on a subform that has it's recordsource dynamically created by an option group on the parent form (criteria in query changes by the value of the option group button selected).
Problem:
If a textbox that has focus contains a misspelled word and the option group is clicked, ctlSpell does not exist and it throws a 2424 error. Strangely, I tested this in a textbox that contains properly spelled words and it works fine. No worries here but strange nonetheless.
Question:
Can I fire the spellcheck as part of the option group click event? So in effect the function could complete before the recordsource for the subform is changed. If this might work, how would I pass ctlSpell (the active control prior to clicking the option group) back to the function when the option group has already been clicked? Perhaps there is a better way but my limited knowledge of Access is tapped at the moment.
Thanks for looking and for providing any assistance you can.
Code:
Public Function SpellChecker(Calling As Form)
On Error GoTo Err_SpellChecker
Dim ctlSpell As Control
Dim Incoming As String, Outgoing As String
DoCmd.SetWarnings False
Set ctlSpell = Calling.ActiveControl
If (ctlSpell.Locked) Then
Line1 = "Cannot spell check. Field is read-only"
mbResult = MsgBox("OK", "", "", Line1)
Else
If (ctlSpell) > 0 Then
Incoming = ctlSpell
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
Outgoing = ctlSpell
End If
' See if any changes were made 09/29/04
If (Incoming <> Outgoing) Then
' Notify user that changes
' were made, if you want to,
' or give Bronx cheer
End If
End If
DoCmd.SetWarnings True
exit_SpellChecker:
Exit Function
Err_SpellChecker:
Select Case Err.Number
Case 2424
'MsgBox "change rs"
Exit Function
Case 438
MsgBox "438 error"
Case Else
MsgBox Err.Number & "-" & Err.Description
Resume exit_SpellChecker
End Select
End Function
The textboxes that are spell checked reside on a subform that has it's recordsource dynamically created by an option group on the parent form (criteria in query changes by the value of the option group button selected).
Problem:
If a textbox that has focus contains a misspelled word and the option group is clicked, ctlSpell does not exist and it throws a 2424 error. Strangely, I tested this in a textbox that contains properly spelled words and it works fine. No worries here but strange nonetheless.
Question:
Can I fire the spellcheck as part of the option group click event? So in effect the function could complete before the recordsource for the subform is changed. If this might work, how would I pass ctlSpell (the active control prior to clicking the option group) back to the function when the option group has already been clicked? Perhaps there is a better way but my limited knowledge of Access is tapped at the moment.
Thanks for looking and for providing any assistance you can.
Comment