Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010

    Question Unanswered: Form Unload Event

    Is there a way to keep your "Dirty" text data in their control's upon the form Unload event being called?

    I have about 20 - 30 text boxes populated with data, and whenever the user clicks to close the form I am displaying a message box - "are you sure you want to close?" to prevent accidental exiting.

    However, once this event is invoked the form's text data is wiped(as it has not been saved - and I don't want it saved at that point)

    Is there anyway around having the text data removed, or something I can do to work around these actions of the "unload" event? (Aside from creating 30 different variables to store the text data in individually)


  2. #2
    Join Date
    Dec 2004
    Madison, WI
    You could try the me.undo command. I rarely use the Unload event but instead will put code in a button and control how the form works via it's properties. For example, I'll design my forms as popup = true and modal = true and control the form's closing via a button. (and also set the form's Control Box property to false so the user can't bypass by clicking the X). This gives me much more control over how I want the form to perform.

    Otherwise, without declaring a bunch of variables, another option is to simply make the form unbound and write a function to write the data to the table again, when a button is pushed (although this does require a bit of coding for writing 20-30 fields to the table.)

    If you want to see an example of how I prevent users from closing the form (and closing MSAccess!), there's a neat little trick I use - see here: or here:

    Notice in the examples, I open a 'MainFormBackground' and maximize it as my startup form. In the OnOpen event of the MainFormBackground, I'll then open my popup/modal menu form. This essentially disables the MSAccess top menus (but does allow the menu when print previewing.) I use this trick all the time and it works very well. Plus, I like the ability of total control on the flow of the program and forms via using popup/modal forms.

    For an unbound form example:

    for additional form controlling features (and making some neat looking form designs), see here:
    Last edited by pkstormy; 04-07-10 at 22:55.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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