+ Reply to Thread
Results 1 to 7 of 7

Userform multipage control exit events code execution not completed before next user entry

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Userform multipage control exit events code execution not completed before next user entry

    Hi

    I have a multipage userform. On each mutlipage tab I have multiple text boxes and/or combo boxes. These are used to collect data and populate an excel database; and also to read/edit the data from the database. Each control has an exit event to check data entry ie - validity; missing; equivalent to the record in the database; or different to the record in the database. This code needs to run before the user clicks into another text box as the result of the data check changes other data in the form.

    The problem is that the code does not always finish executing before the user clicks in another control. If I step through the code in debug mode, it works OK but during normal execution, if the user moves between controls too quickly, it does not run completely.

    Is there a way to force the exit event code to run completely before the user moves to another control?

    I really need help with this as I do not want to have to re-arrange code.

    Thanks

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform multipage control exit events code execution not completed before next user e

    Can't you just set the focus back to the previous control if it fails validation?

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Userform multipage control exit events code execution not completed before next user e

    In some cases it passes validation so it is OK to move to the next control (this is the first part of the code). The next part of the code checks if the data has changed from the database record ie - the variable 'datahaschanged' is set to either true or false. The status of 'datahaschanged' drives 2 items:
    1. if it has not changed the 'total cost' for the record is re-populated with the original data
    2. if the user presses 'calculate costs', a message that the 'data has not changed' is shown.

    This variable is not being updated properly before the user moves to the next control; hence the question re forcing all the code to run.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform multipage control exit events code execution not completed before next user e

    Can you upload a sample workbook, it's difficult to understand the structure of your code

  5. #5
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Userform multipage control exit events code execution not completed before next user e

    Ok - but will need to do it tomorrow though as I am working on a Mac at the moment that doesn't have VBA capacity.

  6. #6
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Userform multipage control exit events code execution not completed before next user e

    Hi Kyle123

    sorry for the delay in getting back to you but I have solved this (went a little crazy though). The code is working fine. The problem is that when I save a record to the database, I am converting one of the textboxes to a number using Val. If the textbox is blank, the code is converting the data to a zero. When I read this record back into the form, the code is stating that the data has changed as the original textbox in the form is blank and then updated to a zero from the record. What I need to happen is for blanks to remain as blanks so I have removed the Val conversion, set the variable to a variant and it works fine.

    I am discovering that you need to be very careful with managing blanks, zeroes and types of variables.

    Thanks

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Userform multipage control exit events code execution not completed before next user e

    Glad you got it sorted

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1