We help IT Professionals succeed at work.

Spell check individual control

PatHartman
PatHartman asked
on
465 Views
Last Modified: 2014-12-09
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

Open in new window

Comment
Watch Question

Tony HungateSenior Manager, Client Services | CISSP
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Distinguished Expert 2017

Author

Commented:
Although I used some of the code from the assisted solution, it didn't actually solve the problem which was getting out of the loop that the spell checker was causing.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.