Spell Check Certain Text Box

A

Abedog308

Hello,

I have placed a spell check button in my form using the following code:

Private Sub Command109_Click()

Dim ctl As Access.Control

For Each ctl In Controls
On Error GoTo Errorhandler
With ctl

If .ControlType = acTextBox Then
..SelStart = 0
..SelLength = Len(.Text)
End If
End With
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
DoEvents
Next ctl


Errorhandler:
Exit Sub

End Sub


When I click my button, I am getting a message that says something about the
field has a required setting equal to true and that is can not contain a null
value.

How can I resolve this issue to allow for a spell check to take place?
 
J

jmonty

The problem stems from the field in your table that the textbox is linked to.
In order to find the textbox culprit, enter a line of code that will tell
you what textbox you are on. Just after the With ctl statement enter a line
like:
Msgbox .Name
As it loops through it should show you the name of each textbox it is
working on.
Now for the error.
(At Least) One of the textboxes has its ControlSource property linked to a
field in a table...and this field has been defined (in Table design mode) to
be a required field. When it is blank/Null Access enforces the rule and will
not allow you to insert a new record without that field being populated. I
know you are not trying to do the inset yet, but it may have something to do
with the way the Spell Checker works behind the scenes.
QUICK FIX:
Change the Required property (in Table design) for the field to No.
If you still need to have it required, use code to validate it instead -
that is if spell checker is a must have! If not, find a way to exclude that
particular textbox from the spell checker routine.

jmonty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top