Spell Checker

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi I am using the following:
If Len(Me.Comments4) > 0 Then
DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

The problem I have I only want it to check the spelling in my field
Comments4 at the moment it spell checks the whole form. How do I change the
code to keep it in the Comment4 field?

Thanks Bob
 
Bob said:
Hi I am using the following:
If Len(Me.Comments4) > 0 Then
DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

The problem I have I only want it to check the spelling in my field
Comments4 at the moment it spell checks the whole form. How do I change the
code to keep it in the Comment4 field?


To do that, you have to select the text you want to check.

If the Comments text box does not have the focus, then give
it the focus
Me.Comments4.SetFocus

Then select the text in the text box:
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

Now you can use the spell checker the way you want.
 
Hi Marsh I have change the code as follows, is this correct?

Because it now comes up with the an error saying The macro or function in
the beforeupdate is preventing Access from saving the data in this field.

The only event set in this field is the one below the afterupdate

If Len(Me.Comments4) > 0 Then
Me.Comments4.SetFocus
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

It worked before so what have I done wrong?

Regards Bob
 
That looks correct, but the BeforeUpdate event is the wrong
place. Use the AfterUpdate (or maybe Exit) event instead.
 
Marsh it is in the Afterupdate event, there is no code in any other event.

If I use the on exit you go round in circles and cannot get out of the
Comments 4 field it comes up with spell check ok then gos back into the
field Comments4

Bob
Marshall Barton said:
That looks correct, but the BeforeUpdate event is the wrong
place. Use the AfterUpdate (or maybe Exit) event instead.
--
Marsh
MVP [MS Access]

Hi Marsh I have change the code as follows, is this correct?

Because it now comes up with the an error saying The macro or function in
the beforeupdate is preventing Access from saving the data in this field.

The only event set in this field is the one below the afterupdate

If Len(Me.Comments4) > 0 Then
Me.Comments4.SetFocus
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

It worked before so what have I done wrong?


"Marshall Barton" wrote
 
If you are using either the text box's AfterUpdate or Exit
event, then remove the SetFocus. The text box already has
the focus and setting it might interfere with normal user
navigation.

The error message you posted earlier said the problem is in
the BeforeUpdate event so there is something out of whack
here.
 
Marsh the error message is still the same and it is in the before up date
but there is no event in the before update
if you take line 3 and 4 out of the code it works but it does the whole form
with no errors the setfocus makes no difference.

Bob

Private Sub Comments4_AfterUpdate()
If Len(Me.Comments4) > 0 Then
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling

Else
Exit Sub
End If
End Sub
Marshall Barton said:
If you are using either the text box's AfterUpdate or Exit
event, then remove the SetFocus. The text box already has
the focus and setting it might interfere with normal user
navigation.

The error message you posted earlier said the problem is in
the BeforeUpdate event so there is something out of whack
here.
--
Marsh
MVP [MS Access]

Marsh it is in the Afterupdate event, there is no code in any other event.

If I use the on exit you go round in circles and cannot get out of the
Comments 4 field it comes up with spell check ok then gos back into the
field Comments4
 
The error also relates to a validation rule and its a memo field does that
make any difference?

Bob
Bob said:
Marsh the error message is still the same and it is in the before up date
but there is no event in the before update
if you take line 3 and 4 out of the code it works but it does the whole
form with no errors the setfocus makes no difference.

Bob

Private Sub Comments4_AfterUpdate()
If Len(Me.Comments4) > 0 Then
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling

Else
Exit Sub
End If
End Sub
Marshall Barton said:
If you are using either the text box's AfterUpdate or Exit
event, then remove the SetFocus. The text box already has
the focus and setting it might interfere with normal user
navigation.

The error message you posted earlier said the problem is in
the BeforeUpdate event so there is something out of whack
here.
--
Marsh
MVP [MS Access]

Marsh it is in the Afterupdate event, there is no code in any other
event.

If I use the on exit you go round in circles and cannot get out of the
Comments 4 field it comes up with spell check ok then gos back into the
field Comments4

That looks correct, but the BeforeUpdate event is the wrong
place. Use the AfterUpdate (or maybe Exit) event instead.


Bob wrote:
Hi Marsh I have change the code as follows, is this correct?

Because it now comes up with the an error saying The macro or function
in
the beforeupdate is preventing Access from saving the data in this
field.

The only event set in this field is the one below the afterupdate

If Len(Me.Comments4) > 0 Then
Me.Comments4.SetFocus
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

It worked before so what have I done wrong?


To do that, you have to select the text you want to check.

If the Comments text box does not have the focus, then give
it the focus
Me.Comments4.SetFocus

Then select the text in the text box:
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

Now you can use the spell checker the way you want.>> Bob wrote:


Bob wrote:
Hi I am using the following:
If Len(Me.Comments4) > 0 Then
DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

The problem I have I only want it to check the spelling in my field
Comments4 at the moment it spell checks the whole form. How do I
change
the
code to keep it in the Comment4 field?
 
It also comes up wit a 2nd error the field may be locked or read only after
the first error message. There are no locks and its not read only. Hope
this helps Bob
Bob said:
Marsh the error message is still the same and it is in the before up date
but there is no event in the before update
if you take line 3 and 4 out of the code it works but it does the whole
form with no errors the setfocus makes no difference.

Bob

Private Sub Comments4_AfterUpdate()
If Len(Me.Comments4) > 0 Then
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling

Else
Exit Sub
End If
End Sub
Marshall Barton said:
If you are using either the text box's AfterUpdate or Exit
event, then remove the SetFocus. The text box already has
the focus and setting it might interfere with normal user
navigation.

The error message you posted earlier said the problem is in
the BeforeUpdate event so there is something out of whack
here.
--
Marsh
MVP [MS Access]

Marsh it is in the Afterupdate event, there is no code in any other
event.

If I use the on exit you go round in circles and cannot get out of the
Comments 4 field it comes up with spell check ok then gos back into the
field Comments4

That looks correct, but the BeforeUpdate event is the wrong
place. Use the AfterUpdate (or maybe Exit) event instead.


Bob wrote:
Hi Marsh I have change the code as follows, is this correct?

Because it now comes up with the an error saying The macro or function
in
the beforeupdate is preventing Access from saving the data in this
field.

The only event set in this field is the one below the afterupdate

If Len(Me.Comments4) > 0 Then
Me.Comments4.SetFocus
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

It worked before so what have I done wrong?


To do that, you have to select the text you want to check.

If the Comments text box does not have the focus, then give
it the focus
Me.Comments4.SetFocus

Then select the text in the text box:
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

Now you can use the spell checker the way you want.>> Bob wrote:


Bob wrote:
Hi I am using the following:
If Len(Me.Comments4) > 0 Then
DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

The problem I have I only want it to check the spelling in my field
Comments4 at the moment it spell checks the whole form. How do I
change
the
code to keep it in the Comment4 field?
 
There must be a problem with the code if I move it to the on change event
Access closes down. After trying to change the spelling error again if you
take the 2 lines of code out it works fine. There is something that it
doesn't like in that code some where.
Bob said:
It also comes up wit a 2nd error the field may be locked or read only
after the first error message. There are no locks and its not read only.
Hope this helps Bob
Bob said:
Marsh the error message is still the same and it is in the before up date
but there is no event in the before update
if you take line 3 and 4 out of the code it works but it does the whole
form with no errors the setfocus makes no difference.

Bob

Private Sub Comments4_AfterUpdate()
If Len(Me.Comments4) > 0 Then
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling

Else
Exit Sub
End If
End Sub
Marshall Barton said:
If you are using either the text box's AfterUpdate or Exit
event, then remove the SetFocus. The text box already has
the focus and setting it might interfere with normal user
navigation.

The error message you posted earlier said the problem is in
the BeforeUpdate event so there is something out of whack
here.
--
Marsh
MVP [MS Access]


Bob wrote:
Marsh it is in the Afterupdate event, there is no code in any other
event.

If I use the on exit you go round in circles and cannot get out of the
Comments 4 field it comes up with spell check ok then gos back into the
field Comments4

That looks correct, but the BeforeUpdate event is the wrong
place. Use the AfterUpdate (or maybe Exit) event instead.


Bob wrote:
Hi Marsh I have change the code as follows, is this correct?

Because it now comes up with the an error saying The macro or function
in
the beforeupdate is preventing Access from saving the data in this
field.

The only event set in this field is the one below the afterupdate

If Len(Me.Comments4) > 0 Then
Me.Comments4.SetFocus
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

It worked before so what have I done wrong?


To do that, you have to select the text you want to check.

If the Comments text box does not have the focus, then give
it the focus
Me.Comments4.SetFocus

Then select the text in the text box:
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

Now you can use the spell checker the way you want.>> Bob wrote:


Bob wrote:
Hi I am using the following:
If Len(Me.Comments4) > 0 Then
DoCmd.RunCommand acCmdSpelling
Else
Exit Sub
End If

The problem I have I only want it to check the spelling in my field
Comments4 at the moment it spell checks the whole form. How do I
change
the
code to keep it in the Comment4 field?
 
Except for your erratic indenting, the code looks good now.

The BeforeUpdate error message is the key. Since that takes
place before the spell check I think you should try removing
the validation rule. Another thing to try is comment out
the spell check line and leave the validation rule in place
so you can see if the two thing are interrelated or not.

Placing a few breakpoints in the code (e.g. on the If
statement) might help shed some light on things too.
 
Marsh I have now tried everything I can but still end up with errors. So I
opened up a new blank db and entered the same named memo field and then
entered the same code this still gives error messages. I have also tried
this on a different computer but still end up with an error. Is there an
error in the code?

Regards Bob

Marshall Barton said:
Except for your erratic indenting, the code looks good now.

The BeforeUpdate error message is the key. Since that takes
place before the spell check I think you should try removing
the validation rule. Another thing to try is comment out
the spell check line and leave the validation rule in place
so you can see if the two thing are interrelated or not.

Placing a few breakpoints in the code (e.g. on the If
statement) might help shed some light on things too.
--
Marsh
MVP [MS Access]

Marsh the error message is still the same and it is in the before up date
but there is no event in the before update
if you take line 3 and 4 out of the code it works but it does the whole
form
with no errors the setfocus makes no difference.

Private Sub Comments4_AfterUpdate()
If Len(Me.Comments4) > 0 Then
Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)
DoCmd.RunCommand acCmdSpelling

Else
Exit Sub
End If
End Sub
 
Do you get the error before or after the break point on the
spell check line?

What, exactly, do you have in the text box's control source.
 
The error occurs when it tries to replace the incorrectly spelt word, the
memo field has no controls and no events. I don't thing it can be the memo
field because we get the same problem in a brand new db with only one field.

Regards Bob

Marshall Barton said:
Do you get the error before or after the break point on the
spell check line?

What, exactly, do you have in the text box's control source.
--
Marsh
MVP [MS Access]

Marsh I have now tried everything I can but still end up with errors. So I
opened up a new blank db and entered the same named memo field and then
entered the same code this still gives error messages. I have also tried
this on a different computer but still end up with an error. Is there an
error in the code?


"Marshall Barton" wrote
 
So, there is no error when the code stops on the spell check
line. Then when you let the code continue, you get the
misspelled word dialog and then the error. This implies
that there is something about the field bound to the text
box control that won't allow the field's value to be
replaced. This something could be a validation rule in
either the text box control's properties or in the table's
field.

Beyond that, I am out of ideas.
 
Marsh if that was the case when you take the 2 lines of code out why doesn't
it bring up the error message

Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

With those lines taken out it replaces the misspelt word in Comments4 and
moves on to the next word if finds in one of the other fields.
If there was a validation rule conflict then wouldn't I still get an error
message?

What are those 2 lines of code telling it to do?

Thanks Bob


Marshall Barton said:
So, there is no error when the code stops on the spell check
line. Then when you let the code continue, you get the
misspelled word dialog and then the error. This implies
that there is something about the field bound to the text
box control that won't allow the field's value to be
replaced. This something could be a validation rule in
either the text box control's properties or in the table's
field.

Beyond that, I am out of ideas.
--
Marsh
MVP [MS Access]

The error occurs when it tries to replace the incorrectly spelt word, the
memo field has no controls and no events. I don't thing it can be the memo
field because we get the same problem in a brand new db with only one
field.

Regards Bob

"Marshall Barton" wrote
 
Bob said:
Marsh if that was the case when you take the 2 lines of code out why doesn't
it bring up the error message

Me.Comments4.SelStart = 0
Me.Comments4.SelLength = Len(Me.Comments4)

With those lines taken out it replaces the misspelt word in Comments4 and
moves on to the next word if finds in one of the other fields.
If there was a validation rule conflict then wouldn't I still get an error
message?

What are those 2 lines of code telling it to do?


Your reasoning makes sense, but something may or may not be
happening when spellcheck starts scanning all the fields in
all the records.

Those two lines do the same thing as dragging the mouse over
the contents of the text box. The spellcheck line then does
the same thing as clicking on the Tools - Spelling menu
item.

What I don't understand is why the message say's it's in the
BeforeUpdate event.
 
Marshall I cant add any more to this I am at a loss as to why it doesn't
work.

Thanks for trying.

Bob
 
I've done the same thing lots of times and never run into a
problem, so it's very frustrating to reach a dead end in
such a simple operation.
--
Marsh
MVP [MS Access]

Marshall I cant add any more to this I am at a loss as to why it doesn't
work.

Thanks for trying.

Bob
 
Marsh I have entered the code into a command button on click event and it
works fine. So I will use this instead.
Thanks for your help
Bob
Marshall Barton said:
I've done the same thing lots of times and never run into a
problem, so it's very frustrating to reach a dead end in
such a simple operation.
 
Back
Top