Spell Check Problem in sub-Form

smbarney

Registered User.
Local time
Yesterday, 23:23
Joined
Jun 7, 2006
Messages
60
Hi All,

I am using the following code (thanks ICEZEBRA) to spell check certain fields upon exit.

Private Sub YOURFIELDNAME_Exit(Cancel As Integer)
Dim strSpell
strSpell = YOURFIELDNAME
If IsNull(Len(strSpell)) Or Len(strSpell) = 0 Then
Exit Sub
End If
With YOURFIELDNAME
.SetFocus
.SelStart = 0
.SelLength = Len(strSpell)
End With
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End Sub

This works great on the main form. However, when I try it on any of the sub-forms, it starts spell checking all of the fields. How do I get it to check only the fields I want when that field is on a sub-form?

It would be great to turn this into a public action in which you could just put "=spellchecker()" in the on exit event and it would do the rest. Thanks for the help.
 
i assume the problem is in referring to the control on the subform:
Me.sfrmName.Form!ctlName
if you just refer to the subform control then i suppose it will do the whole thing.
 
Okay...tired Me.sfrmName.Form!ctlName and no luck. If I set to strSpell = Me.cltName it works. However, it also check all of the other fields on the sub-form. This one has got me stumped.
 
Just a thought: what about creating a public function that ran the spell check?

Something like this:

in the on exit event : =spellcheck("")

On subforms, you simply put in the name of the subform in quotes, otherwise it is ignored (I think I saw a calendar pop up that works like this). My problems is a I can't figure out how to setfocus and still run the above spelling code.

Any thoughts?
 

Users who are viewing this thread

Back
Top Bottom