[AccessD] Spell Check

Dan Waters dwaters at usinternet.com
Mon Oct 29 13:49:16 CDT 2007


Hi Rocky,

To do spellchecking on textboxes I use this code I've developed through
trial & error.  It works pretty well - although I've had one 'user' try to
paste a long email into a textbox field and then crash the whole database.
I retrained him in alternate methods!

First, you need to declare a modular variable for each form you'll be using
this in like this: 


	Private MvarOriginalText As Variant


Second, you need to enter the following into the Enter and Exit events of
each textbox (here called memDescription):


	Private Sub memDescription_Enter()

    		MvarOriginalText = memDescription

	End Sub

	Private Sub memDescription_Exit(Delete As Integer)

    		Call SpellCheckField(memDescription, MvarOriginalText)
    		MvarOriginalText = memDescription
    
	End Sub


Third, put these two procedures into a standard module:


	Public Sub SpellCheckField(varField As Variant, varOriginalFieldText
As Variant)
    
    		If IsNull(varField) Or varField = "" Then
        		Exit Sub
    		End If
    
    		If varField = varOriginalFieldText Then
        		Exit Sub
    		End If
    
    		Call Spellcheck
    
    		Exit Sub

	End Sub

	Public Sub Spellcheck()

    		Dim ctl As Control
    		Dim lngText As Long
    		Dim varFieldContents As Variant
    
    		Set ctl = Screen.ActiveControl

    		If Not ctl.ControlType = acTextBox Then
        		Exit Sub
    		End If

    		If ctl.Locked = True Then
        		Exit Sub
    		End If
    
    		If ctl.Enabled = False Then
        		Exit Sub
    		End If

    		ctl.SelStart = 0
    		ctl.SelLength = Len(ctl.Text)
    
    		DoCmd.SetWarnings False
    		DoCmd.RunCommand acCmdSpelling
    		DoCmd.SetWarnings True
    
    		Set ctl = Nothing
    
    		Exit Sub
    
	End Sub

This ends up working the way a person would probably intuitively expect
automatic spellchecking to work.  The user doesn't have to take any action,
it just pops up the spellchecking window if something is misspelled, and
doesn't do anything at all if all the text is spelled correctly.

Hope this helps!

Dan


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
Beach Access Software
Sent: Monday, October 29, 2007 1:12 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Spell Check

Dear List:
 
Is there a way through code to trigger the spell checker on a specific
field?   I think the F7 hotkey does all the fields.   
 
MTIA
 
Rocky
 

 
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com











































































































































































More information about the AccessD mailing list