spell checking error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.

Thanks in advance for any help.

Richard
 
I can't see anything wrong with that code, but I do know that the following
works without problems. Put the following code in a standard module and name
the module anything but the same as the function. It will check every
textbox on the form. Now you can simply call it from a command button like:

=Spell()

Public Function Spell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
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
End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
I appreciate the reply. I'll give it a try at least to see if I still get the
same error. But realistically, I cannot use this because most of my text
fields are people's names and other things where if those fields got checked,
I'd be wasting time clicking Ignore most of the time.

Richard
 
Richard said:
I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.


I think the error message means what it says - this time ;-)

Try moving the code to the control's AfterUpdate event.
 
Try moving the code to the control's AfterUpdate event.<

What exactly do you mean? What control? remember, I am a total novice at
this. thanks

Richard
 
Well, I tried it and can't get this to work without a debug error. So, I
guess my lack of Access knowledge is really showing. Anyways, thanks for
trying to help. I appreciate it. I'll just have to be careful and watch my
typing for now.
 
I finally figured out what you were asking. It IS in the AfterUpdate event
for my text box.
 
marshall,

This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.
 
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.
 
Well, This is whata is in the AfterUpdate of that field. Btw, I was wrong on
one thing. This is a memo field, not a text field, if that makes a difference.

Private Sub Resolution_AfterUpdate()
Me.Resolution.SelStart = 0
Me.Resolution.SelLength = Len(Me.Resolution.Text)
DoCmd.RunCommand acCmdSpelling
End Sub

I clicked in all other Event fields for this memo field, and they are all
blank. As a matter of fact, there are only 3 other private events, all for On
Click.



Marshall Barton said:
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.
--
Marsh
MVP [MS Access]


This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.
 
Well this is strange. I tried a test with this code and I
got the same error message, so I went back to an old app
that does this and found that I had used a separate command
button to initiate the spell check, not the text box's
AfterUpdate event.

The code behind the button is:

Private Sub cmdSpell_Click()
With Me.txtNotes
.SetFocus
If Len(.Text) > 0 Then
.SelStart = 0: .SelLength = Len(.Text)
DoCmd.RunCommand acCmdSpelling
End If
End With
cmdSpell.SetFocus
End Sub

Sorry about the memory fault.
--
Marsh
MVP [MS Access]



Well, This is whata is in the AfterUpdate of that field. Btw, I was wrong on
one thing. This is a memo field, not a text field, if that makes a difference.

Private Sub Resolution_AfterUpdate()
Me.Resolution.SelStart = 0
Me.Resolution.SelLength = Len(Me.Resolution.Text)
DoCmd.RunCommand acCmdSpelling
End Sub

I clicked in all other Event fields for this memo field, and they are all
blank. As a matter of fact, there are only 3 other private events, all for On
Click.



Marshall Barton said:
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.

This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.


Richard wrote:
I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.


:
I think the error message means what it says - this time ;-)

Try moving the code to the control's AfterUpdate event.
 
Woohoo.. You Rock Marsh. That worked like a charm.

Richard

Marshall Barton said:
Well this is strange. I tried a test with this code and I
got the same error message, so I went back to an old app
that does this and found that I had used a separate command
button to initiate the spell check, not the text box's
AfterUpdate event.

The code behind the button is:

Private Sub cmdSpell_Click()
With Me.txtNotes
.SetFocus
If Len(.Text) > 0 Then
.SelStart = 0: .SelLength = Len(.Text)
DoCmd.RunCommand acCmdSpelling
End If
End With
cmdSpell.SetFocus
End Sub

Sorry about the memory fault.
--
Marsh
MVP [MS Access]



Well, This is whata is in the AfterUpdate of that field. Btw, I was wrong on
one thing. This is a memo field, not a text field, if that makes a difference.

Private Sub Resolution_AfterUpdate()
Me.Resolution.SelStart = 0
Me.Resolution.SelLength = Len(Me.Resolution.Text)
DoCmd.RunCommand acCmdSpelling
End Sub

I clicked in all other Event fields for this memo field, and they are all
blank. As a matter of fact, there are only 3 other private events, all for On
Click.



Marshall Barton said:
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.


Richard wrote:
This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.


Richard wrote:
I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.


:
I think the error message means what it says - this time ;-)

Try moving the code to the control's AfterUpdate event.
 
Apparently a separate command button works, but why doesn't the AfterUpdate
work? Anyone - cause I get this error too.

Bruce.
**********
Marshall Barton said:
Well this is strange. I tried a test with this code and I
got the same error message, so I went back to an old app
that does this and found that I had used a separate command
button to initiate the spell check, not the text box's
AfterUpdate event.

The code behind the button is:

Private Sub cmdSpell_Click()
With Me.txtNotes
.SetFocus
If Len(.Text) > 0 Then
.SelStart = 0: .SelLength = Len(.Text)
DoCmd.RunCommand acCmdSpelling
End If
End With
cmdSpell.SetFocus
End Sub

Sorry about the memory fault.
--
Marsh
MVP [MS Access]



Well, This is whata is in the AfterUpdate of that field. Btw, I was wrong on
one thing. This is a memo field, not a text field, if that makes a difference.

Private Sub Resolution_AfterUpdate()
Me.Resolution.SelStart = 0
Me.Resolution.SelLength = Len(Me.Resolution.Text)
DoCmd.RunCommand acCmdSpelling
End Sub

I clicked in all other Event fields for this memo field, and they are all
blank. As a matter of fact, there are only 3 other private events, all for On
Click.



Marshall Barton said:
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.


Richard wrote:
This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.


Richard wrote:
I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.


:
I think the error message means what it says - this time ;-)

Try moving the code to the control's AfterUpdate event.
 
Have you tried the BeforeUpdate event? It makes far more sense to me to
check the spelling before you save the value.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"2.0 to 2000 converter - Bruce"
Apparently a separate command button works, but why doesn't the AfterUpdate
work? Anyone - cause I get this error too.

Bruce.
**********
Marshall Barton said:
Well this is strange. I tried a test with this code and I
got the same error message, so I went back to an old app
that does this and found that I had used a separate command
button to initiate the spell check, not the text box's
AfterUpdate event.

The code behind the button is:

Private Sub cmdSpell_Click()
With Me.txtNotes
.SetFocus
If Len(.Text) > 0 Then
.SelStart = 0: .SelLength = Len(.Text)
DoCmd.RunCommand acCmdSpelling
End If
End With
cmdSpell.SetFocus
End Sub

Sorry about the memory fault.
--
Marsh
MVP [MS Access]



Well, This is whata is in the AfterUpdate of that field. Btw, I was wrong on
one thing. This is a memo field, not a text field, if that makes a difference.

Private Sub Resolution_AfterUpdate()
Me.Resolution.SelStart = 0
Me.Resolution.SelLength = Len(Me.Resolution.Text)
DoCmd.RunCommand acCmdSpelling
End Sub

I clicked in all other Event fields for this memo field, and they are all
blank. As a matter of fact, there are only 3 other private events, all for On
Click.



:
Sorry, but that clue only adds to my confusion.

How about posting a copy/paste of the text box's AfterUpdate
and BeforeUpdate event procedures. Actually, AFAICT, the
text box shouldn't have a BeforeUpdate procedure. Since the
message is talking about saving the record, I'd like to see
the Form's BeforeUpdate procedure too.

While you're at it, double check that each of these event
properties have [Event Procedure] and not something strange
in them.


Richard wrote:
This is wierd. I still get that error when using the code. But, if I use F7
and have Window spell-check it, I get no error. It updates the mispelled
word, and no errors or problems.


Richard wrote:
I got this code from another question in here to do spell checking in a text
box.

Me.textbox.SelStart = 0
Me.textbox.SelLength = Len(Me.textbox.Text)
DoCmd.RunCommand acCmdSpelling

The error I am getting is after I select the correctly spelled word from the
checker. I get:

The macro or the function set to the BeforeUpdate or ValidationRule Property
is preventing Database from saving the data in this field.

The it goes on to say that the field may be locked or read-only.

I am at a loss since neither is the case. The text field is just a plain
text box. I don't use macro's and I don't have the field read-only sicne I
can go in and type whatever I want.


:
I think the error message means what it says - this time ;-)

Try moving the code to the control's AfterUpdate event.
 
Back
Top