Spell Check For Multiple TextBoxes (1 Viewer)

stu_c

Registered User.
Local time
Today, 17:06
Joined
Sep 20, 2007
Messages
489
Hi all
I have the below code for two text boxes when the command button is clicked it checks these two TextBoxes which works fine, the only issue is that once its searched the first box it comes up with spell check complete then moves to the second and does the same, is it possible to change the code slightly so it automatically checks both boxes then shows just one spell check complete?

I was wondering if there is a way in the code to group TEXTBOX1 and TEXTBOX2 under one code name maybe sort the issue?

Code:
 With Me![TEXTBOX1]
     If Len(.Value) > 0 Then
            .SetFocus
            .SelStart = 1
            .SelLength = Len(.Value)
            DoCmd.RunCommand acCmdSpelling
            .SelLength = 0
        End If
    End With
    With Me![TEXTBOX2]
     If Len(.Value) > 0 Then
            .SetFocus
            .SelStart = 1
            .SelLength = Len(.Value)
            DoCmd.RunCommand acCmdSpelling
            .SelLength = 0
        End If
    End With
    
DoCmd.SetWarnings True
 

Minty

AWF VIP
Local time
Today, 17:06
Joined
Jul 26, 2013
Messages
10,368
Not easily as it relies on selecting the text and using the inbuilt office spell checker on the highlighted text.

As a suggestion, why not spell check each text box directly after it's updated, then you would only get interrupted after either one was changed ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:06
Joined
May 7, 2009
Messages
19,233
there was a thread similar to your dilemma and has been
unsolved.

the only thing I can think is create a user-define spell checker.
 

GinaWhipp

AWF VIP
Local time
Today, 12:06
Joined
Jun 21, 2011
Messages
5,900
I took Arvin's code and modified slightly to only check cream colored controls. Then you just need to change the back color for the text boxes you want to apply spell check to and you only get one message for completion.

Code:
Public Function Spell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
' RTW Adapted to check only Backcolor of cream

        Dim ctlSpell As Control
        Dim frm As Form
        Set frm = Screen.ActiveForm
        
        DoCmd.SetWarnings False
        ' Enumerate Controls collection.
        For Each ctlSpell In frm.Controls
           If TypeOf ctlSpell Is TextBox Then
                If ctlSpell.BackColor = RGB(254, 252, 248) Then
                 If Len(ctlSpell) > 0 Then
                     With ctlSpell
                     .SetFocus
                     .SelStart = 0
                     .SelLength = Len(ctlSpell)
                     End With
                     DoCmd.RunCommand acCmdSpelling
                     MsgBox "Spell Check complete!", vbInformation + vbOKOnly, "Spell Check"
                 End If
               End If
            End If
        Next
        DoCmd.SetWarnings True
        
End Function
 

stu_c

Registered User.
Local time
Today, 17:06
Joined
Sep 20, 2007
Messages
489
Hello Gina
Thank you for the below code, so your saying to manually change the colour of the text boxes I want to spell check to RGB 254, 252, 248?

If this is the case how do I change it to this colour as I can only choose from a selection of colours?

I took Arvin's code and modified slightly to only check cream colored controls. Then you just need to change the back color for the text boxes you want to apply spell check to and you only get one message for completion.

Code:
Public Function Spell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
' RTW Adapted to check only Backcolor of cream

        Dim ctlSpell As Control
        Dim frm As Form
        Set frm = Screen.ActiveForm
        
        DoCmd.SetWarnings False
        ' Enumerate Controls collection.
        For Each ctlSpell In frm.Controls
           If TypeOf ctlSpell Is TextBox Then
                If ctlSpell.BackColor = RGB(254, 252, 248) Then
                 If Len(ctlSpell) > 0 Then
                     With ctlSpell
                     .SetFocus
                     .SelStart = 0
                     .SelLength = Len(ctlSpell)
                     End With
                     DoCmd.RunCommand acCmdSpelling
                     MsgBox "Spell Check complete!", vbInformation + vbOKOnly, "Spell Check"
                 End If
               End If
            End If
        Next
        DoCmd.SetWarnings True
        
End Function
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:06
Joined
Sep 21, 2011
Messages
14,235
You use the color picker (... then More Colors) with any RGB values then Access will give you the hex value which is #FEFCF8

Colour can be any colour you want.

HTH
 

Users who are viewing this thread

Top Bottom