Full Version: Spell Check Fields In Sub Form
UtterAccess Forums > Microsoft® Access > Access Forms
sherri_k
I need to set up a spell check button on one of my forms to check the spelling of the contents of a specific field in one of it's subforms.
The subform is a datasheet and therefore may contain multiple records in respect of the current record shown on the parent form and the spell check button needs to check the contents of a specific field but across all records shown in the datasheet subform.
Hope this makes sense?
I have checked previous topics relating to spell check commands and am having trouble applying the code provided.
I would be extremely grateful if someone could assist with the code required for my situation - please bear in mind that i am not code literate!
Many thanks
Sherri
dashiellx2000
Can you provide the code you are currently attempting?
sherri_k
I tried adapting this:
CODE
Sub SpellCheck_Click ()
         On Error GoTo SpellCheck_Err
         Dim WordObj As Object
         ' Set the object variable to the form's embedded OLE control.
         Set WordObj = Me![MyOle].Object.Application.WordBasic
         ' Activate the embedded control.
         MyOle.Action = 7
         ' Specify a WordBasic function to perform.
         WordObj.ToolsSpelling
         ' Deactivate the embedded control.
         MyOle.Action = 9
         Exit Sub
         SpellCheck_Err:
            If Err = 2763 Then
               MsgBox "The Spell Check is Complete."
               Resume Next
            End If
      End Sub

which was a link provided on one of the previous threads - but without success as I was unsure how to apply it,
Oalso tried:
CODE
Sub PerformSpellCheck(FieldName As String)    
     If Nz(Me(FieldName)) = "" Then Exit Sub    
     DoCmd.SetWarnings (False)  
     Me(FieldName).SetFocus    
     Me(FieldName).SelStart = 0    
     Me(FieldName).SelLength = Len(Me(FieldName))    
     DoCmd.RunCommand acCmdSpelling        
     DoCmd.SetWarnings (True)    
End Sub

and could adapt this successfully either!
dashiellx2000
The first code looks like it belongs on the click event of a command button. I'm assuming you changed the a name of Me![MyOle] to match the control name on your form.
The second, is a Function and belongs in the module section of the database. Then on the click event of a button on the form, you'd put Call PreformSpellCheck (Me.ControlName).
I use something a lot more basic:
DoCmd.GoToControl "RefundExplanation"
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True
HTH.
sherri_k
Presumably "RefundExplanation" needs to be replaced with the reference to the field I need to spell check?
This being the case - I am not sure how to refer to it because it is a field in a subform, what is the correct syntax?
sherri_k
Thanks you for your help - I have now managed to get it working.
uch appreciated!
sherri_k
By using the following code:

CODE
Me.SfrmMWSub.SetFocus
oCmd.GoToControl "CommentsMemo"
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
DoCmd.SetWarnings True

Ocan get it to spell check the required field for the first record in the subform, but I need it to loop through all records in the subform - any suggestions?

Edited by: sherri_k on Wed May 24 7:12:47 EDT 2006.
dashiellx2000
You might be able to use the tag property of the control to force Access to loop through them and preform the spell check. I have an idea how to do this, but let me test it and I'll report a solution if I find one.
dashiellx2000
It worked. Here is the code I put in on the Click Event of a command button on a continuous form:
!--c1-->
CODE
Dim ctl As Control
DoCmd.SetWarnings False
For Each ctl In Me.Controls
    If ctl.Tag = "SpellCheck" Then
        DoCmd.GoToControl ctl.Name
        DoCmd.RunCommand acCmdSpelling
    End If
Next ctl
DoCmd.SetWarnings True

You need to put SpellCheck as the Tag for the control you want to check on it's Other Property tab.
HTH.
sherri_k
I know that I am being really quite thick about this, but I don't understand what you mean by
You need to put SpellCheck as the Tag for the control you want to check on it's Other Property tab"
I would be extremely grateful if you could provide an idiots guide to what exactly it is that I need to do.
What code should go against the button on the main form that is used to activate the spell check and how do I apply it relative to my fields in the subform that need to be checked?
Sorry to be a pain!
dashiellx2000
You are not being thick at all. We are all still learning this program we call Access.
When you select the control that you want to spell check right click and select properties. Goto the Other tab and find the line that states Tag or Control Tag (Depends on which version you are using). Type in SpellCheck.
I'd put the button itself, if all it is going to do is spell check, on the subform.
I've attached a small demo db to demonstrate what I'm an talking about. It is in A97 format so you'll probably have to convert it up to what ever version you are using.
HTH.
sherri_k
Thanks again for your assistance and perseverance with this blush.gif)
I have to have the button on the parent form rather than the subform for 2 reasons, firstly because it has to fit with the design in the rest of the forms in the database and secondly the subform is in datasheet view.
I have tried implementing the example you kindly included but it doesn't seem to do anything when I add it into my db?
sherri_k
I am having a mare! I re-tested your original code and it now seems to work - i.e. it is looping through all the records!
Not sure why there was a problem in the first place as all I did was comment it out and then uncomment it out!
Its working so I am not complaining.
Thank you very much for your kind assistance - you are a gem.
dashiellx2000
You're welcome. Glad I could help.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.