Results 1 to 9 of 9
  1. #1
    MrMom is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2016
    Location
    Virginia
    Posts
    11

    What button was clicked - order of events

    I have a startup form that prompts the user for a Vendor and one other piece of information. The Vendor is critical as everything else is dependent upon the selection. I have a Vendor_Exit procedure that then loads parameters about the Vendor, etc. and it gives a warning if the Vendor has not been selected. However, I also have a Skip button that allows the user to bypass the startup form and go directly to the next form to perform startup steps manually and there is also a button that allows the user to close the application. The problem is that I get the warning message when the Skip or Close button has been clicked.

    According to Microsoft, the event sequence is as follows:
    First control:
    Exit LostFocus
    Second control:


    Enter GotFocus MouseDown MouseUp Click

    In this case the First control is Vendor and the Second Control is the Skip or Close buttons. As a result, the Vendor_Exit procedure displays the warning message. Is there a way to identify in Vendor_Exit which button was clicked and not display the message?

    My alternative is to remove the code from the Vendor_Exit procedure and add a Vendor verification step to the controlxxx_Enter procedure for every other control on the startup form.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Try adding a Boolean variable e.g. blnSkip and set it true if the skip or close buttons are clicked
    Then add an If line to the Vendor_Exit code
    Code:
    If blnSkip=False then 
      Your warning message goes here
    End If
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    MrMom is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2016
    Location
    Virginia
    Posts
    11
    I did try that but because the Exit procedure of the first control (Vendor) occurs before the Enter procedure of the second control (the buttons), it doesn't get set until after the message is displayed. I also tried testing Me.ActiveControl.Name in the Exit procedure and it still says 'Vendor'.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Would it work if you used code to set focus to the next control when you click either of the skip or close buttons?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    maybe have a single button 'proceed'

    Then have a diaglog box open up if no vendor is selected

    i.e.
    Code:
    dim response
    
    if isnull(vendor_ID) then
        response = msgbox("No Vendor has been selected" & vbcrlf & vbcrlf & "Do you want to continue with a manual setup?", vbyesno, "Confirm Manual Setup")
        if response = vbyes then
            <do what you'd do on a manual start>
        endif
    else
       <do what you'd do on a vendor selected start>
    endif

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Do you have to be in the vendor field to start with? If it's not going to be mandatory validate but dont enter it?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    MrMom is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2016
    Location
    Virginia
    Posts
    11
    Micron,
    Wonderfully simple solution! When the StartUp form loads, I can set the focus to the Close button or the Skip button since neither of these are dependent upon the Vendor being selected eliminating the execution of the Vendor_Exit procedure. I'll try that today and let you know how it goes.


    Changes made and error message no longer appears when user hits Skip or Close! Thank you!
    Last edited by MrMom; 12-03-2018 at 08:10 AM. Reason: Problem solved!

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    A close or cancel button is usually 0 in my form tab order. Giving it the focus not only provides for a quick Enter key press to close form if user opens wrong one (or whatever), it allows user to start anywhere on the form.

  9. #9
    MrMom is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2016
    Location
    Virginia
    Posts
    11
    I like that approach. Mine is usually last in the tab order with 0 being the first control I expect a user to interact with. I'm going to change and adopt your strategy.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-23-2017, 06:28 PM
  2. Replies: 2
    Last Post: 03-16-2016, 12:33 PM
  3. Saving a Record Edit ONLY if button is clicked?
    By McArthurGDM in forum Forms
    Replies: 3
    Last Post: 06-01-2015, 09:33 PM
  4. Order of events on forms?
    By John_G in forum Forms
    Replies: 8
    Last Post: 11-29-2011, 04:18 PM
  5. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 AM

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