Results 1 to 15 of 15
  1. #1
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127

    onclose event

    Hello! I'm not entirely sure how to do this, but I have a form which opens when the database is opened for a person to enter some information to begin working in the database. When the person is done with the database, and tries to close out, for instead the same form that comes up at start to appear with a message box saying something like, "Before closing, please click the "Time End" button." Then, after clicking the button, it will allow you to close out. I'm pretty new to Access so I don't know what to do with this.

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This can all be accomplished with the first form just make it invisible when the user moves on to other forms instead of closing it.

  3. #3
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    thanks but i have two questions, how do I make my form invisible, and what will making it invisible do for what I wanted? The way I read what you said was that the form with the time end button will be invisible when im on other forms. This will be the only form that is in the database my group and I will be working in. would it work if I created a seperate form that was invisible, once I found out how to do this, that opened when the database is closed out of with the time end button on it? this way the user wouldn't be tempted to click it while in the first form.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I guess I don't understand how your form interact. How many forms do you have and which one has the "Time End" button?

  5. #5
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    I have one form that opens when the database opens. This form has the Time End button which uses the Now() expression to enter the time into a field. All I need is this form to open when someone tries to close the database.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How do you close this form after it opens?

  7. #7
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    I've just been leaving it open, or I manually close out of it by right clicking the tab then selecting close.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why do they have to press the TimeEnd button? Why not just assume they did and do the same thing when the db closes. You can do it in the UnLoad event of that form.

  9. #9
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    I suppose that would work. But as a user, would you be comfortable with having to leave a form up, or that you would remember to keep it up?


    ****EDIT****

    I've come around to the idea of leaving the form up, however my idea now is to have a message box to confirm that the user wishes to close the form, activating the code in the unload properties. I want this to simply say, "click yes to log-out. Click cancel to return to the form." This would be the best option for me at this point.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can Cancel the UnLoad event and set the form Visible along with your message. Lots of options here.

  11. #11
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    thanks, but might you be able to give me a little bit more of an idea on what exactly to do?

    What I think your saying is that there is a way to cancel the UnLoad event, and if that were possible, wouldn't it be easier to just put this in the OnClose event instead? This way instead of when the form uses the information when it's being closed, this way I may be able to simply cancel the OnClose Event, keeping the form open. This, however, I still have no idea how to do. Any help would be appreciated.

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The UnLoad event occurs before the Close event and can be canceled where the Close event can not; that is why I suggested the UnLoad event. Start by putting Cancel = True in the UnLoad event and see what happens.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Then you could change it to:
    If Me.Visible = False Then
    Me.Visible = True
    Cancel = True
    End If

  14. #14
    imintrouble is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    Missouri, where frownin's a sport
    Posts
    127
    figured it all out Thanks so much! One last thing then my project shall be complete

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That's great!

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

Similar Threads

  1. Form_Load Event
    By Juan4412 in forum Programming
    Replies: 4
    Last Post: 07-12-2011, 04:12 PM
  2. Replies: 7
    Last Post: 03-15-2011, 11:14 PM
  3. Help on an event...
    By allykid in forum Forms
    Replies: 4
    Last Post: 03-15-2011, 11:25 AM
  4. Before Update Event
    By randolphoralph in forum Programming
    Replies: 0
    Last Post: 06-15-2010, 09:26 AM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 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