Results 1 to 7 of 7
  1. #1
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22

    Unload called when opening a form?

    Hello,

    Let me explain the situation first.
    I am trying to capture the Unload event of a Popup Modal form to check if a combo box has been filled in properly (i.e. item exists, combo box isn't empty) because I'm having trouble capturing during the Update event.
    I figure if I can catch the Unload event and if something's wrong, I can prevent the closing of the popup modal form. However, this event appears to be called when the popup modal form is being opened, which I don't quite get. What am I doing wrong?




    If I have a misunderstanding about capturing a value that doesn't exist in the list or if the box is empty, I apologize and if possible, could you send me in the right direction.

    Thank you for your time.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    IMHO, a form's UnLoad event is the best place to do validation. It does not fire until the form tries to close. I know this sounds silly, but are you sure your code is not in the form's Load event.
    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
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22
    Quote Originally Posted by Bob Fitz View Post
    IMHO, a form's UnLoad event is the best place to do validation. It does not fire until the form tries to close. I know this sounds silly, but are you sure your code is not in the form's Load event.
    I checked again and it was in the Unload event. However its working now. Weird. Perhaps its because I had the popup form already open in the design view when I ran the function that opened the popup form?
    Anyhow, thank you for replying to my question. I appreciate it and I agree about it being the best place for validation if the form is going to be closing.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Actually I've made a very silly mistake. I meant to say that validation is best done in the form's Before update event. Sorry, I was trying to do two things at the same time.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    I knew you knew better, Bob! Thought maybe you'd started on the eggnog a little early!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Missinglinq View Post
    I knew you knew better, Bob! Thought maybe you'd started on the eggnog a little early!

    Linq ;0)>
    No, no eggnog........yet. Just tiredness and trying to do two things at once. Now, if I were a woman.......................
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Kirtap is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    22
    I couldn't get any validation working for some reason. I basically just want to prevent the default not in list warning. I guess I could do acErrContinue(name?) in the NotInList event of the combobox I'm working with followed by some sort of validation.

    I'm guessing the NotInList occurs before BeforeUpdate?
    Edit: Sorry if I'm going offtopic, but I guess I'm trying to find the best way of preventing an error by finding the order of events. I also discovered that the reason Unload is triggering first is because I have code that closes the form if its already open (i.e. I have it open in a design form.)

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

Similar Threads

  1. Replies: 2
    Last Post: 11-17-2012, 06:03 PM
  2. Replies: 0
    Last Post: 03-11-2012, 09:19 AM
  3. Replies: 4
    Last Post: 08-16-2011, 10:04 AM
  4. Replies: 0
    Last Post: 05-04-2010, 06:39 AM
  5. Replies: 1
    Last Post: 03-26-2010, 10:32 PM

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