Rocky Smolin at Beach Access Software
rockysmolin at bchacc.com
Mon Oct 29 14:03:43 CDT 2007
That will definitely help. I'll probably define some hot key to trigger the
spell check since the user may want it off - or maybe a check box and use
the enter/exit approach.
The DoCmd.RunCommand acCmdSpelling if call separately, does that normally
run on all the text boxes on the form or just the text box that has the
focus?
Thanks and regards,
Rocky
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Monday, October 29, 2007 11:49 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Spell Check
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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.12/1097 - Release Date: 10/28/2007
1:58 PM