Issue with Spell Check Cancel

G

Guest

I have a data entry form that I have automatically run a spell check before
it saves the data. However, if I select the Cancel option from the spell
check dialog box, instead of just cancelling the spell check operation, my
data edits get cancelled/undone. Is there a way that I can capture this
event so that I prevent the loss of my edits? Thanks in advance for any
advice.
 
A

Arvin Meyer

Make your own function then you can call and cancel it without problems. The
following code has been tested for almost 7 years:

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
 
G

Guest

The code you provided launched the spell check for the entire form each time
it found a text field. But that issue aside, even if I used the function to
launch the spell check once, I was still losing my data. Apparently, the
cancel of the spell check was cancelling my form's record update event. The
simple fix to that (the data gets stuffed into a tmp table anyway) was to
issue a DoCmd.Runcommand acCmdSaveRecord. That forced the record save and
now all is well. However, if there is a way to capture the cancel via the
Spell function, I'd appreciate learning what to do to make that happen
because that would be the better solution. Thanks for your assistance.
 
A

Arvin Meyer

You must be running the code in the form's Before Update event. Try running
it in the After Update instead. You can still change a value after it has
been saved, but you can't reverse it back to it's unsaved version
automatically. You don't need to do that anyway.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
G

Guest

I didn't realize that about being able to change the data after its saved.
In fact, in my situation, I was running the spell check before closing the
form. I'll try your suggestion. Sounds promising. Thanks.

gt
 
G

Guest

As it turned out, running the spell check in the After Update would not work
in my instance. It kept saying the data could not be changed. My problem
turned out to be when I was running the append query. It finally worked
right when I put the append in the Form UnLoad event. Leaving the Spellcheck
in the in the Save button's OnClick event worked fine after that. Thanks
again for the help.
 

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