Start Spell Check From Within Access

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

Guest

I enhance Access for the local food bank to track volunteers. Some people
have trouble spelling organization names correctly. I want to invoke the
Spellcheck DLL available within Access for just the contents of the
Organization text box, rather than the one from the menu bar which tries to
check every text box starting with the
beginning of the file. I want to check only organization names as they are
added. Other text boxes, including for organization names, are combo boxes
with tables behind them which can autofill.

I placed the code Alex Dybenko's site shows using a Form_BeforeUpdate event
procedure and I watched it step through the code. When it gets to the
SetFocus method, a message appears stating "You must save the field before
you execute the GoToControl action, the GoToControl method, or the SetFocus
method." The text box is titled "Organization."

If Not IsNull(Me!Organization) Then
If Len(Me!Organization) = 0 Then
Else
With Me.Organization
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
End if
End if

Prior answers by John W. Vinson asked why I typed the names at all. I had
incorrectly given the impression that "Organization" text box did not have a
table behind it. Douglas J. Steele also said Alex's code works for him too.
Alex pointed out that there is no Windows API for this, which expands my
knowledge.

Since I get an error message, it means I am doing something wrong. I changed
the code to run in an AfterUpdate event. Still no response for misspelled
words.

Please spell out what event procedure you use for this code and how you
invoke it. I can't seem to get it to work.

EarlCPhillips
Ex-Mainframer Learning Access To Make
Feeding the Hungry More Efficient
 
Drop the .SetFocus
If it is in the BeforeUpdate event the control hasn't lost focus yet.

Also, if you think about it, you have a field that has been edited (if it
hadn't the event wouldn't fire) but not been saved yet. GoToControl or
SetFocus would not be valid ways to save the data edit.
 
I removed the ".SetFocus", but I also removed the "DoCmd.SetWarnings False"
and the "DoCmd.SetWarnings True" instructions in order to see warning
messages. Then I received the message "The spellchecker only works on text
fields that contain text data." with a sub-note of "You're trying to check a
field with a data type other than Text or Memo."

I checked and the Organization field is a combo box. When I change it to a
text box, I receive the message "Spellcheck complete." When I put in
multiple deliberately misspelled words, only the first word is changed before
an error message is received stating "The macro or function set to the
BeforeUpdate or ValidationRule property for this field is preventing
Volunteer Database from saving the data in this field."

I am still experimenting to find the situation and parameters that will
allow spell checking to work as I expect it to work, such as in Word. It
must be checking a text or memo box, etc. which eliminates my auto-fill from
a combo-box-lookup. If I ever fully understand it, I will post a further
note on what I found.

EarlCPhillips
Ex-Mainframer Learning Access To Help
Feed the Hungry More Efficiently
 
Back
Top