• Spell check a particular field

    Author
    Topic
    #464115

    Hi,

    I’ve used code posted by Hans in a previous post to add this code to the “On Exit” function of the BillTitle field. It seems to work fine and allows me to change the spelling. However if I go to click into another field but ‘ignore’ or ‘cancel’ the suggestion box, the cursor goes back into the same field and when I try to click out of it I get the same error – essentially I get stuck in a loop until I accept the suggestion. Here is the code I’ve implemented:

    Private Sub BillTitle_Exit(Cancel As Integer)
    ‘If the textbox contains data run the Spell Checker after data is entered.
    If Len(Me!BillTitle & “”) > 0 Then

    With Me!BillTitle
    .SelStart = 0
    .SelLength = Len(.Text)
    End With
    DoCmd.SetWarnings False ‘ If there are no errors, don’t report spell check is complete
    DoCmd.RunCommand acCmdSpelling
    DoCmd.SetWarnings True ‘ Turn warnings back on
    Else
    Exit Sub
    End If
    End Sub

    If anyone can help that would be great.

    Cheers,

    Viewing 5 reply threads
    Author
    Replies
    • #1186939

      Do you have other event code for the BillTitle text box? I can’t reproduce the problem that you mention (in Access 2002 SP3) – if I ignore a suggestion or cancel the spell check dialog, the focus moves to the control I clicked in.

      • #1187323

        Do you have other event code for the BillTitle text box? I can’t reproduce the problem that you mention (in Access 2002 SP3) – if I ignore a suggestion or cancel the spell check dialog, the focus moves to the control I clicked in.

        HI Hans,

        There is no other event code for the BillTitle text box. I’ve also tried this code in another text box (that also does not have any other event code) and I get the same problem. I’m using Access 2003. Any other ideas?

        Cheers,
        Jason

    • #1186943

      I have tested your code using 2007, and I also don’t have problems if I Cancel or Ignore.

    • #1187328

      I attach a demo that uses your code, and works without problem for me.
      Does it work for you?
      If it does, can you post a similar example that does display the problem you describe?

      • #1187496

        I attach a demo that uses your code, and works without problem for me.
        Does it work for you?
        If it does, can you post a similar example that does display the problem you describe?

        Hi John,

        Yes, the demo you attached works for me.

        I’ve attached a cut-down copy of my database which just includes a single form and table – I’m still having the problem in this database.

        Cheers,
        Jason

        • #1187499

          The problem appears to be caused by the tab control. If the text boxes are on a tab control, the focus doesn’t shift if you cancel the spell check, but without the tab control, focus does shift.

          This appears to be a bug in Access, I don’t know a solution (except doing without the tab control).

          • #1188380

            The problem appears to be caused by the tab control. If the text boxes are on a tab control, the focus doesn’t shift if you cancel the spell check, but without the tab control, focus does shift.

            This appears to be a bug in Access, I don’t know a solution (except doing without the tab control).

            Hi guys,

            Thanks for your help so far. I’m still trying to figure out why mine doesn’t work, but the example that John posted does work.

            When you say tab control, do you mean that you can tab to the fields because they are part of the tab order (View>Tab Order)? If so, John’s example has the same setup but his works, so again I’m not sure why mine doesn’t.

            Thanks,
            Jason

    • #1187518

      If you explicitly set the focus to another control after turning warnings back on it seems to work.

      Code:
      DoCmd.SetWarnings True ' Turn warnings back on
      Me.BilInfo_Description.SetFocus
      

      PS In the demo you posted, the control that display the field BilInfo_Descrition is actually named something else. For this to work you need to rename it.

      • #1187521

        If you explicitly set the focus to another control after turning warnings back on it seems to work.

        It does, but it means that users can’t move to another control by clicking on it – they will always end up in the one you set focus to in the code. So for example clicking a button at the top of the form won’t work if the user cancels the spell check dialog.

    • #1187522

      I agree that setting the focus to a specific field might not be very usable. I was just offering it as a suggestion that Jason could consider.

      If, in practice, most users tab through this form to create new records, and the data, once entered, tends not to be edited much, it might work.

    • #1188390

      Hans mean the Tab Control on your form:

      • #1189662

        Hans mean the Tab Control on your form:

        Hi Francois (and others) – once again, thanks for your help so far, but I’m still not sure what I’m supposed to remove or modify in order to get spell check to work (Also bear in mind that I didn’t design this database from scratch and am also a newbie to Access!)

        If I go to the properties of the page (Eg, Proposal page), I don’t see anything mentioned about tabs. If someone can point me in the right direction as to what I need to remove or modify that would be great.

        Cheers,
        Jason

        • #1189690

          The BillTitle and BilInfo_Description text boxes are placed on a tab control named TabCtl102:

          Try the following experiment (use the stripped down copy of the database that you attached):

            [*]Select the text boxes and their labels.
            [*]Press Ctrl+X to cut them to the clipboard.
            [*]Click just to the right of Proposal to select the tab control.
            [*]Press Delete to remove the tab control.
            [*]Press Ctrl+V to paste the text boxes directly onto the form.
            [*]While they are still selected, drag them to the position where you want them.
            [*]The text boxes have lost the connection to their event code. To repair this:
            [*]Select BillTitle, then select [Event Procedure] from the dropdown list in the On Exit event on the Event tab of the Properties window.
            [*]Do the same for BillInfo_Description.

          Now switch to form view and test the spelling checker.

          Here is the database with these changes. I didn’t modify anything else.

        • #1189693

          I don’t see anything mentioned about tabs. If someone can point me in the right direction as to what I need to remove or modify that would be great.

          Further to Hans comments that tell you how to remove the Tab control.

          A tab control allows you to have several ‘pages’ within the one form.

          Tab controls only have a point when they have more than 1 tab (or page). The db you posted has a form with a tab control that has just one page (tab). In that case it makes sense to follow Hans advice and just remove the tab control and move the other controls directly to the form itself.
          However, if the real db has multiple pages (tabs) that option would become complicated as there would be other issues to deal with.

          • #1189956

            Further to Hans comments that tell you how to remove the Tab control.

            A tab control allows you to have several ‘pages’ within the one form.

            Tab controls only have a point when they have more than 1 tab (or page). The db you posted has a form with a tab control that has just one page (tab). In that case it makes sense to follow Hans advice and just remove the tab control and move the other controls directly to the form itself.
            However, if the real db has multiple pages (tabs) that option would become complicated as there would be other issues to deal with.

            Hi Hans and John,

            Thanks again for your help. My database does have multiple pages (I just removed for them for the demo I posted), so I think I’ll leave this one for now and let the users know they’ll just have to use the spell check button on the top of the form.

            Cheers,
            Jason

    Viewing 5 reply threads
    Reply To: Spell check a particular field

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: