G
Guest
MS Access 2K, Windows XP
====================
Hi,
I'm trying to spell check the textbox and memo controls on a form and a
subform. Thanks to Arvin Meyer's code, I'm able to spell-check the controls
on the form.
But, is there a way to spell-check the controls on a subform? I only have
one subform on a form (meaning one level down) and no nested subforms within
a subform.
I modified the code but I'm getting an "Application defined or
object-defined error" when I run the code.
I have a button on the form that calls this function which is defined in a
module. I'm quite sure that the problem is with referencing the subform
controls, but I don't know how to correct it. I think maybe the focus needs
to be set to the subform.
Will appreciate any help/pointers in the right direction. Thanks!
-Amit
PS. Also, just wondering if it is possible to use recursion here to deal
with nested subforms- just a thought, not that I need it...as of now
Here's the code with my comments in ">>"
========================================================
Public Function fSpell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
Dim ctlSpell, sf_ctlSpell As Control
'>>I added sf_ctlSpell to refer to subform controls
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
'>> I added (ctlSpell.visible = true) as I have some invisible textbox
controls
'>> on my form
If ctlSpell.Visible = True And TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
If TypeOf ctlSpell Is SubForm Then
Forms![frm]![ctlSpell].Forms.SetFocus
'iterate through all the controls of the subform and spellcheck
For Each sf_ctlSpell In frm.ctlSpell.Controls
'>> I've tried a few variations in the above line like
Me!ctlSpell.Forms!Control
'>> and Forms!ctlSpell.Forms!Control w/o success.
If sf_ctlSpell.Visible = True And TypeOf sf_ctlSpell Is
TextBox Then
If Len(sf_ctlSpell) > 0 Then
With sf_ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(sf_ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next
End If
Next
DoCmd.SetWarnings True
End Function
========================================================
====================
Hi,
I'm trying to spell check the textbox and memo controls on a form and a
subform. Thanks to Arvin Meyer's code, I'm able to spell-check the controls
on the form.
But, is there a way to spell-check the controls on a subform? I only have
one subform on a form (meaning one level down) and no nested subforms within
a subform.
I modified the code but I'm getting an "Application defined or
object-defined error" when I run the code.
I have a button on the form that calls this function which is defined in a
module. I'm quite sure that the problem is with referencing the subform
controls, but I don't know how to correct it. I think maybe the focus needs
to be set to the subform.
Will appreciate any help/pointers in the right direction. Thanks!
-Amit
PS. Also, just wondering if it is possible to use recursion here to deal
with nested subforms- just a thought, not that I need it...as of now
Here's the code with my comments in ">>"
========================================================
Public Function fSpell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
Dim ctlSpell, sf_ctlSpell As Control
'>>I added sf_ctlSpell to refer to subform controls
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
'>> I added (ctlSpell.visible = true) as I have some invisible textbox
controls
'>> on my form
If ctlSpell.Visible = True And TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
If TypeOf ctlSpell Is SubForm Then
Forms![frm]![ctlSpell].Forms.SetFocus
'iterate through all the controls of the subform and spellcheck
For Each sf_ctlSpell In frm.ctlSpell.Controls
'>> I've tried a few variations in the above line like
Me!ctlSpell.Forms!Control
'>> and Forms!ctlSpell.Forms!Control w/o success.
If sf_ctlSpell.Visible = True And TypeOf sf_ctlSpell Is
TextBox Then
If Len(sf_ctlSpell) > 0 Then
With sf_ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(sf_ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next
End If
Next
DoCmd.SetWarnings True
End Function
========================================================