Results 1 to 4 of 4
  1. #1
    Lhoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2021
    Posts
    94

    Getting the control that raises an error

    Hi there,

    i'm currently making significant changes to the structure and to the various forms on my DB. Right now I'm designing a simple form to add records to a table, and probably going the extra complicated and inefficient route with it but that's just who I am. The form has four fields, three of them mandatory. So the submit button is disabled on form load, and only enabled when the three fields (actually 2 comboboxes and 1 text field) are filled.

    So far so good, but I wanted to take it a step further and show the user some indication of why the button is disabled. Enter invisible tags. There is an invisible 'REQUIRED' tag over each of those fields that get visible when the mouse hovers over the disabled button and disappear when it doesn't. First problem, the button is disabled and doesn't trigger the mousemove event. Workaround: I use the mouse move of the whole details section (which I suppose is programmatically super inefficient) and manually trigger disabled button's mousemove event when moving over the area the button is at.

    But for the event to check the fields properly I have to take the focus elsewhere, or else the function doesn't register the changes on the active field (i.e, I edit the text field, hover the mouse over the button without exiting the text field, it will show the tag over the edited text, as if the field was still empty). So I set the focus out of any field before checking the values and showing (or not) the tags.

    Here comes my problem. The comboboxes are set to be restricted to the list, but I want the user to be able to type instead of being forced to choose from the list with the mouse, so I don't want to disable typing on the comboboxes. But if I type something that's not on the list, then hover the mouse over the button, access throws an error as it can't take the focus out of the combobox since the value is not valid. So, I handle the error, and if the number belongs to said error, I simply remove the text from the combobox and continue with the function as normal (setting the focus elsewhere). The problem is now I have two comboboxes. I need to know which one throws the error to delete the text from that one and leave the other unchanged. But when I check the err.Source property it just says 'Database' with both of them.

    Any way to pin the error to its source? I have at least dozen alternatives to handling this form, but I'd really like to make this one work.

    Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps use the combo's Not In List event to save the combo name to a variable
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Lhoj is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2021
    Posts
    94
    Genius! It's working perfectly now!

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Lhoj View Post
    Genius! It's working perfectly now!
    "Genius"?? Thank you for your kind words but I know you're wrong about that.
    However, I'm glad if I've helped you to find a solution
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. #Error in calculated control despite error handling
    By TrainingExcellence in forum Access
    Replies: 2
    Last Post: 08-07-2019, 07:45 PM
  2. Replies: 15
    Last Post: 05-12-2016, 02:27 PM
  3. #Name? error in a control
    By GregHankins in forum Access
    Replies: 1
    Last Post: 01-19-2013, 08:36 PM
  4. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  5. Replies: 6
    Last Post: 09-28-2011, 09:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums