I am using this code to perform spell checks (not sure where I got it, but it works a peach):
Public Function SpellChecker(Calling As Form)
On Error GoTo Err_SpellChecker
Dim ctlSpell As Control
Dim Incoming As String, Outgoing As String
Set ctlSpell = Calling.ActiveControl
If (ctlSpell.Locked) Then
Line1 = "Cannot spell check. Field is read-only"
mbResult = MsgBox("OK", "", "", Line1)
If (ctlSpell) > 0 Then
Incoming = ctlSpell
.SelStart = 0
.SelLength = Len(ctlSpell)
Outgoing = ctlSpell
' 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
Select Case Err.Number
'MsgBox "change rs"
MsgBox "438 error"
MsgBox Err.Number & "-" & Err.Description
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).
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.
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.