Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Posts
    108

    Unanswered: Knowing which control on form triggered On Error event?

    I have 3 combo boxes that have "Limit to list" values set to true, thus when a user choses something outside list error 2237 is triggered and intercepted by me with a custom dialog box!

    However I would like to know WHICH CONTROL (in this case which of 3 combo boxes) triggered form's On Error event?

    Thanks!

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Not really sure you'd want to use the form's On Error event in this situation. If the combobox is set to limit to list, you can utilize the "On Not in List" event of the combobox which supplies 2 options in the event (NewData which equals the new data entered) and (Response where you can control what response to send)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    And to answer the question, you could use the Screen.ActiveControl to return the name of the object
    Last edited by StarTrekker; 12-10-07 at 04:28.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Apr 2007
    Posts
    108
    Thanks pkstormy (I was blessed with ignorance, never knew that event existed)...

    ...and

    ... thanks StarTrekker I like to know the solution even if it's not needed now!

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Screen.ActiveControl
    That's one for my notes!
    George
    Home | Blog

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    There's a calendar example in the code bank I posted which utilizes the screen.activecontrol if you want to see it utilized.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Screen.PreviousControl is pretty funky too
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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