I would like to run spell check on a few controls (using A2013 runtime) and I don't want the user to have to push a button to make this happen because they just forget. So, I added the code to call the spell check to the on Exit event (that is the only event that works. Both Before and After update raise errors and Change isn't even a consideration.) of the controls I want to spellcheck. Below is the suggested code. I commented out a few lines that were causing a problem but it still creates a never ending loop. It seems to make Access forget where it was going when the LostFocus event was interrupted. The other piece of code from the same website that checks all the controls on a form works fine. But for this form, I have tab controls and those are interfering with the spell checker when it tries to set focus to a control.
I tried a couple of things such as comparing the .value property to the .oldvalue property. That works to avoid the spell check when the user is just tabbing through the controls without changing anything but once something is changed, the values are different so the spell checker keeps running.
It would be nice if there were some property that told us where Access thought it was going next so the spell check could just move the focus there but I don't know of any.
Private Sub cmdSpell_Click() Dim ctlSpell As Control Set ctlSpell = Screen.PreviousControl If TypeOf ctlSpell Is TextBox Then If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then ''''MsgBox "There is nothing to spell check." ''''ctlSpell.SetFocus Exit Sub End If With ctlSpell .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) End With DoCmd.RunCommand acCmdSpelling Else MsgBox "Spell check is not available for this item." End If '''ctlSpell.SetFocus End Sub
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
-Mike Kapnisakis, Warner Bros
With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. You'll also be able to connect with highly specified Experts to get personalized solutions to your troubleshooting & research questions. It’s like crowd-sourced consulting.
We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need.
Our certified Experts are CTOs, CISOs, and Technical Architects who answer questions, write articles, and produce videos on Experts Exchange. 99% of them have full time tech jobs - they volunteer their time to help other people in the technology industry learn and succeed.
We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.