Spell Checker (1 Viewer)

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
I have put a spell check in a DB I have just created. It works but It tries and correct to field.

The two fields it corrects are “verse” short text, and “story” long text. I want it to correct “story” long text, only.
Private Sub cmdSpellCheck_Click()

If Len(Me.story) > 0 Then

DoCmd.RunCommand acCmdSpelling

End If

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:18
Joined
Sep 21, 2011
Messages
14,044
How does it correct Verse if you are not calling it for that control?
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
How does it correct Verse if you are not calling it for that control?
That is what I am asking. There's just test data in a few records so far. Want me to attach it?
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
attachment
 

Attachments

  • DailyDevotions.zip
    52.7 KB · Views: 659

Gasman

Enthusiastic Amateur
Local time
Today, 17:18
Joined
Sep 21, 2011
Messages
14,044
Ok, I see what you mean, so I think it is checking the whole form and Verse happens to be the first control.?

I have only used the spell checker once in my DB,s and did it this way JUST for the relevant control.?
Code:
Call SpellChecker(Me.ActiveControl)

and in a module
Code:
Public Sub SpellChecker(txt As TextBox)
    On Error GoTo Err_SpellChecker
    
    If Trim(txt & " ") <> "" Then
        'Handles null, emptystring, and space or spaces
        'Only way this fails if you have not prinatble characters only ex. VBCRLF
        DoCmd.SetWarnings False
        txt.SetFocus
        txt.SelStart = 1
        txt.SelLength = Len(txt.Value)
        DoCmd.RunCommand acCmdSpelling
        txt.SelLength = 0
        'Debug.Print txt.Value
        DoCmd.SetWarnings True
    End If

Exit_SpellChecker:
    DoCmd.SetWarnings True
    Exit Sub
    
Err_SpellChecker:
    MsgBox "Error No.: " & Err.Number & vbNewLine & vbNewLine & _
           "Description: " & Err.Description & vbNewLine & vbNewLine & _
           "Function: SpellChecker" & vbNewLine & _
           IIf(Erl, "Line No: " & Erl & vbNewLine, "") & _
           "Module: basTest", , "Error: " & Err.Number
    Resume Exit_SpellChecker
    
End Sub

as you just want it on story for now this appears to work.

Code:
Private Sub cmdSpellCheck_Click()
If Len(Me.story) > 0 Then
        Me.story.SetFocus
        Me.story.SelStart = 1
        Me.story.SelLength = Len(Me.story)
        DoCmd.RunCommand acCmdSpelling
End If
End Sub
and go the module route if you wish to do more.

HTH
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
Ok, I see what you mean, so I think it is checking the whole form and Verse happens to be the first control.?

I have only used the spell checker once in my DB,s and did it this way JUST for the relevant control.?
Code:
Call SpellChecker(Me.ActiveControl)

and in a module
Code:
Public Sub SpellChecker(txt As TextBox)
    On Error GoTo Err_SpellChecker
   
    If Trim(txt & " ") <> "" Then
        'Handles null, emptystring, and space or spaces
        'Only way this fails if you have not prinatble characters only ex. VBCRLF
        DoCmd.SetWarnings False
        txt.SetFocus
        txt.SelStart = 1
        txt.SelLength = Len(txt.Value)
        DoCmd.RunCommand acCmdSpelling
        txt.SelLength = 0
        'Debug.Print txt.Value
        DoCmd.SetWarnings True
    End If

Exit_SpellChecker:
    DoCmd.SetWarnings True
    Exit Sub
   
Err_SpellChecker:
    MsgBox "Error No.: " & Err.Number & vbNewLine & vbNewLine & _
           "Description: " & Err.Description & vbNewLine & vbNewLine & _
           "Function: SpellChecker" & vbNewLine & _
           IIf(Erl, "Line No: " & Erl & vbNewLine, "") & _
           "Module: basTest", , "Error: " & Err.Number
    Resume Exit_SpellChecker
   
End Sub

as you just want it on story for now this appears to work.

Code:
Private Sub cmdSpellCheck_Click()
If Len(Me.story) > 0 Then
        Me.story.SetFocus
        Me.story.SelStart = 1
        Me.story.SelLength = Len(Me.story)
        DoCmd.RunCommand acCmdSpelling
End If
End Sub
and go the module route if you wish to do more.
Thanks. I will incorporate your code.

two additional comments. 1. If you only used a spell checker once, it must mean you are a better speller than me.

Second was your salutation. I was discussing “free loaders” at my local restaurant with a very political liberal person. He said you are a preacher how can you have that attitude, what does the Bible say about feeding the poor. I said if you don’t work you don’t eat. He said what about the verse that says give a man a fish and he eats for one day, teach him to fish and he eats every day. The rest of us almost fell of our chairs laughing. It’s a virtuous thought but it’s not a Bible verse. Secondly, he somehow missed his own point. If I teach him to fish, that means he has too work, to fish.
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
Worked like a fish, I mean like a charm. BTW the reason I didn’t want to correct verse is that I paste those in and they are in Old English.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:18
Joined
Sep 21, 2011
Messages
14,044
What I meant was that I have only implemented the spelling functionality in one of my DBs and that was only after helping someone with his version. Then I thought 'Why not add one to my charity DB for my notes field?' and so I did. That is where I got the process I highlighted above.

Strangely enough, I could not find much info on exactly how to use it via MS.
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
What I meant was that I have only implemented the spelling functionality in one of my DBs and that was only after helping someone with his version. Then I thought 'Why not add one to my charity DB for my notes field?' and so I did. That is where I got the process I highlighted above.

Strangely enough, I could not find much info on exactly how to use it via MS.
Well I thank you anyways. Better speller than me is an understatement. My sister was swapping email with me one night and asked why my spelling was so bad. I told her my spell checked already went to bed.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:18
Joined
Sep 21, 2011
Messages
14,044
Well thinking about it, I have always been decent at spelling. Used to get gold stars in Primary school. :cool:
Plus spelling mistakes tend to jump out at me.
Just as well these days, as my typing is getting atrocious. :)
 

Dick7Access

Dick S
Local time
Today, 13:18
Joined
Jun 9, 2009
Messages
4,197
Well thinking about it, I have always been decent at spelling. Used to get gold stars in Primary school. :cool:
Plus spelling mistakes tend to jump out at me.
Just as well these days, as my typing is getting atrocious. :)
Gold Stars huh! All I got was whippings!:(
 

vhung

Member
Local time
Today, 10:18
Joined
Jul 8, 2020
Messages
235
I have put a spell check in a DB I have just created. It works but It tries and correct to field.
The two fields it corrects are “verse” short text, and “story” long text. I want it to correct “story” long text, only.

Nice, i like this, useful one.
DoCmd.RunCommand acCmdSpelling
 

Attachments

  • spellCheck.png
    spellCheck.png
    170.3 KB · Views: 662
Last edited:

Users who are viewing this thread

Top Bottom