You’ve seen the Microsoft’s spell checker tool across Word, Excel and other Office applications and it’s even available within Microsoft Access database too.
When entering data into any input control, text box, memo fields or anywhere else users enter text, you can quickly call the spell checker tool using the keyboard shortcut F7.
If you use MS Access forms and in all honesty, you should be using them, you could automate the spell checker tool on selective controls using microsoft access database Access VBA code bound to one of the control’s events so it will automatically pop-up without manually having to call this utility (via F7).
Microsoft Access Database Tutorial – How To Use Spellchecker On A MS Access Form
Here are the simple steps…
In your Access form, decide which control or text box field is going to be used to trap for the spell checker tool and locate the Before Update event via the Properties Sheet (under the Events tab).
In the event’s signature (via the Visual Basic Editor view), enter the following code:
Note: The name of my control is called Text0 but you may want to have renamed this control before loading its event.
Save your changes and test this control in normal run-time view mode. Enter some text and as soon as you hit the enter key you trigger the above code and the spell checker tool will pop-up if there are any miss-pelt or unknown words.
Note the lines DoCmd.SetWarnings False and DoCmd.SetWarnings True which temporarily disables any system warnings but in this example it’s probably over kill as there are no warnings for this type of call DoCmd.RunCommand acCmdSpelling which is the actual spell checker utility being called here.
All other lines that starts with a period (.) is part of the With…End With block which is a short way to avoid repeating the hierarchy object reference (in this case Me.Text0).
Each line is required so the cursor is placed at the beginning of the text string and selects characters for each word in order for the spell checker to validate and highlight. If the word or words are known to the dictionary, nothing will happen (as you would nominally expect with this tool).
You can add a bit more refinement to it so that users can switch on or off the event as it listens for the After Update call by adding a check box control to act as the on/off flag.
To include this flag in your VBA code, takes one line of code.
Assuming you named the new added check box as chk_spell, the above code exit the sub if the value is set as false (unchecked).
Need to know more about Microsoft Access database? Why not consider my eBook bundle containing six eBooks at half price?