Hank Reed wrote:
I am trying to use the spell checker on an unbound control in Access
2000. I run the checker in the AfterUpdate event of the control.
After the spell checker is done, I get the following message:
The Macro or Function set to the BeforeUpdate or ValidationRule
Property for this field is preventing MS Access from saving the data
in the field.
I have no validation code or mask and no code in the Before
Update event.
This is the spell checker code:
Dim ctlSpell As Control
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
If 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
Next
DoCmd.SetWarnings True
Any ideas?
Hank Reed
I made a copy of your form, created a command button called Spell and
ran your code. It ran fine.
I then put your code in the afterupdate event of control and ran it and
got your error.
I then modified your code to below and got the same error.
I then moved the modified code to the LostFocus event and it ran fine.
I am not sure why you want to enumerate all controls when you are
wanting to spellcheck a single control. Anyway, see if the below works
in the LostFocus.
Dim ctlSpell As Control
Set ctlSpell = Me.ActiveControl
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If