SpellCheck Certain Field

Ukraine82

Registered User.
Local time
Today, 02:35
Joined
Jun 14, 2004
Messages
346
I have 20 Fields in a Form. I would like to spellcheck only 1 field instead of whole form. Also, how can I spellcheck only current record instead having it go through all my records.

I just would like to have a spellcheck for one field only in that record. The field that I wish to spellcheck is Claim_Notes.

Thanks,

Michael
 
I was about to ask that one as well. I hope someone has an answer
 
How about a little slight of hand… :D

On any given Form: -

Code:
Option Explicit
Option Compare Text


Private Sub cmdCheckSpelling_Click()
    Dim strSpellCheckFormName As String

    strSpellCheckFormName = "frmCheckSpelling"

    If Nz(Me.txtMyTextBox, "") <> "" Then
    
        DoCmd.OpenForm strSpellCheckFormName, acNormal, , , , acNormal, Me.txtMyTextBox
        
        While IsLoaded(strSpellCheckFormName)
            DoEvents
        Wend
        
        Me.txtMyTextBox = DLookup("SpellCheckField", "tblSpellCheck")
        
    End If

End Sub

And in the Spell Checking Form: -

Code:
Option Explicit
Option Compare Text


Private Sub Form_Open(Cancel As Integer)

    DoCmd.MoveSize 0, 0, 0, 0
    
End Sub


Private Sub Form_Timer()
   
    Me.TimerInterval = 0
    
    Me.txtCheckSpelling = Me.OpenArgs
    
    DoCmd.RunCommand acCmdSpelling
    
    DoCmd.Close acForm, Me.Name
    
End Sub

Supplied as is and with very little testing, A97 demo attached.

Regards,
Chris.
 

Attachments

Something a little more generic…

Code:
Public Sub CheckSpelling(ByRef frmThisForm As Form)
    Dim strSpellCheckFormName As String
    Dim ctlThisControl        As Control
    
    strSpellCheckFormName = "frmCheckSpelling"
    
    DoCmd.SetWarnings False
    
    For Each ctlThisControl In frmThisForm
        Select Case ctlThisControl.ControlType
        
            Case acTextBox
                If Nz(ctlThisControl, "") <> "" Then
                    If ctlThisControl.Tag = "Spell Check Me" Then
                        DoCmd.OpenForm strSpellCheckFormName, acNormal, , , , acNormal, ctlThisControl
              
                        While IsLoaded(strSpellCheckFormName)
                            DoEvents
                        Wend
    
                        ctlThisControl = DLookup("SpellCheckField", "tblSpellCheck")
                    End If
                End If
                
        End Select
    Next ctlThisControl
    
    DoCmd.SetWarnings True
    
    MsgBox "The spelling check is complete.", vbInformation
    
End Sub

Version two is attached.

Regards,
Chris.
 

Attachments

Chris,

Thanks for replying, but there has to be an easy way to do it without making an extra table (tblSpellcheck) or form (frmCheckSpelling).

I've tried using this method, but it seems to be doing a spellcheck for all records.

If Len(FieldName & "") > 0 Then
DoCmd.RunCommand acCmdSpelling
Me.FieldName.SetFocus
End If


Is there an easy to way to do it without making an extra form and/or table?

Thanks,

Michael
 
Nevermind I got it working. Paste the code below if you wish to spell check certain field only in a current record.

'It runs when the text box has data
With Me.FieldName
.SetFocus
.SelStart = 0
.SelLength = Len(Me.FieldName)
End With
DoCmd.RunCommand acCmdSpelling


hth,

Michael
 
G’day Michael.

Thanks for posting the solution… that’s a much better idea. :D

Now if we put your code in the loop posted above we get: -

Code:
Public Sub CheckSpelling(ByRef frmThisForm As Form)
    Dim ctlThisControl As Control
    
    DoCmd.SetWarnings False
    
    For Each ctlThisControl In frmThisForm
        Select Case ctlThisControl.ControlType
        
            Case acTextBox
                If Nz(ctlThisControl, "") <> "" Then
                    If ctlThisControl.Tag = "Spell Check Me" Then
                        With ctlThisControl
                            .SetFocus
                            .SelStart = 0
                            .SelLength = Len(ctlThisControl)
                        End With
                        DoCmd.RunCommand acCmdSpelling
                    End If
                End If
                
        End Select
    Next ctlThisControl
    
    DoCmd.SetWarnings True
    
    MsgBox "The spelling check is complete.", vbInformation
    
End Sub
Which will spell check any text box that has its Tag property set to "Spell Check Me" and ignore all others.

Thanks again and regards,
Chris.
 
I'm having problems with this one !

Hi Chris,
Sorry to have jumped into this thread a little late but it appears to be exactly the answer to my problem.
i.e. I want to spell check just the contents of one field in the current record after it is typed into a memo text box control on a form. I have created a public sub in a module (inline with your last example) which gets called from the afterupdate event of the textbox. When running it selects the text in box OK but then the spellchecker goes off and checks an entirely different field in a control on an underlying form starting at record one and looping through all the entries in that field one by one - not exactly what I had in mind :confused:

The current form ( the one the user is typing in) is set as popup & modal and is opened in response to a cmd button on the underlying form, which, incidentaly is also set as popup & modal !

Have you any suggestions as to why the spellchecker is not checking the selected text ?
 
G’day Stuart and welcome to the site.

Well it’s not exactly what I had in mind either and sounds very strange.

Perhaps the way to go would be to post the code you have or better still a little demo in A97 please.

Regards,
Chris.
 
One step forward....and two steps back

G'day Chris

Thanks for your welcome, and thanks for picking up on my late entry :)

I've tried to replicate the problem in a simple test that kind of replicates how my real app funcions, but gues wot...... it works perfectly :confused:

Well I say perfectly, it enumerates through the controls on the current form correctly, it selects the text correctly, and it even fires up the spellchecker and checks the selected text, just like it is supposed to. It then raises another question that could do with an answer while I try to figure out why this version works and my "real" version doesn't. The spell checker generates an error when it trys to update the field with spelling corrections.

"The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Access from saving the data in the field"

I don't suppose you can spot cause can you ?

Cheers

Stuart
 

Attachments

G’day Stuart.

I can’t tell you exactly why it is occurring but if you move the call to CheckSpelling Sub to the Lost Focus event it seems to work OK.

Hope that helps and, when I get time, I’ll look into just why this occurs in the AfterUpdate event.

Regards,
Chris.
 
Lost Focus

Hi Chris, I trust you are well ?

I don't know about losing focus, I'm loosing the plot, I never have been fully aware of the complete chain of events that happens when you move from one control to another, beforeupdate, afterupdate, changed, lostfocus etc etc.

I've moved the call and you are quite right it does work - bizzare but true

Any chance you would care to take a peek at my "real problem", it's quite a big application (by my standards) so I'll try to strip it down a bit to make it more portable.

Thanks everso for you assistance so far

Regards

Stuart
 
The Plot Thickens

Hi Chris

Well I stripped out all the unecessary code 'n stuff from my app so I could let you have a peak and you will never guess what I found. I'm developing in Access XP (2002) and my spell check does this strange thing checking the wrong data instead of the stuff selected in the current text box. But.......wait for it..........when I convert it to Access97 for you it bloody well works correctly dosn't it :eek:

Don't suppose you can have a look at my native VB6 code from Access 2002 can you ?

Your's in hope

Stuart
 

Users who are viewing this thread

Back
Top Bottom