Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Star Lounger
    Join Date
    Sep 2009
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.


  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I have tested your code using 2007, and I also don't have problems if I Cancel or Ignore.
    Regards
    John



  4. #4
    Star Lounger
    Join Date
    Sep 2009
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    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

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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?

    [attachment=86798:spellcheck.zip]
    Attached Files Attached Files
    Regards
    John



  6. #6
    Star Lounger
    Join Date
    Sep 2009
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by John Hutchison View Post
    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?

    [attachment=86798:spellcheck.zip]
    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
    Attached Files Attached Files

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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).


  8. #8
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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.
    Regards
    John



  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by John Hutchison View Post
    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.

  10. #10
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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.
    Regards
    John



  11. #11
    Star Lounger
    Join Date
    Sep 2009
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    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

  12. #12
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans mean the Tab Control on your form:

    [attachment=86894:tabcontrol.jpg]
    Attached Images Attached Images
    Francois

  13. #13
    Star Lounger
    Join Date
    Sep 2009
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Francois Caron View Post
    Hans mean the Tab Control on your form:

    [attachment=86894:tabcontrol.jpg]
    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

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The BillTitle and BilInfo_Description text boxes are placed on a tab control named TabCtl102:

    [attachment=87007:x.png]

    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.

    [attachment=87008:db1.zip]
    Attached Images Attached Images
    • File Type: png x.png (10.4 KB, 0 views)
    Attached Files Attached Files

  15. #15
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by Jason View Post
    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.
    [attachment=87009:tabs.gif]

    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.
    Attached Images Attached Images
    Regards
    John



Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •