Free Lessons
Fast Tips
Topic Index
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Home > TechHelp > Directory > Access > On Unload < Copy To Clipboard | Force New Page >
Back to On Unload    Comments List
click X twice to close Upload Images   Link   Email  
Sami Shamma              
3 months ago
This has stumped me.
I have this simple code in the unload event of a form.

Private Sub Form_Unload(Cancel As Integer)
    If IsNull(ReportDate) Or ReportDate = "" Then
        MsgBox "You Must enter a date!", vbCritical, "Missing Date"
        Cancel = True
    End If
End Sub

The records in this form are preloaded.
The user must enter a date before he exits.

When closing the form, the code works correctly:
1) the record already has a date. it closes.
2) the record dose NOT have a date. Magbox is displayed.

But if after the msgbox is displayed and a date is entered, I have to click the "X" twice for the form to close.

I thought it may have to do with the record being dirty, so I added me.refresh, but that was not the problem.

I do not understand what is happing with the timing. I tried trapping what is happing without succuss.
Adam Schwanz             
3 months ago
Works perfectly fine for me. Is there any other events going on?

Way out there question and unlikely if the rest of your forms work, but it kind of reminds me of a focus issue, like with zoom remote control you have to actually click into the program once to register your interacting, and then your second click registers as an action. Out of curiosity, does it still do it if you click the form once and then the X once?
Sami Shamma              
3 months ago

You are on to something. If I click on the form once and then click the "X," it closes.
Sami Shamma              
3 months ago

Sami Shamma              
3 months ago
this form has three subforms:
Program Numbers.

all one-to-many with proper ChaplainID as foreign keys to the other three tables
Adam Schwanz             
3 months ago
Welp, I wasn't really expecting that lol. If thats what it is I'm not sure how to address that, are you doing this on your local machine or is it through some kind of remote connection that could be interfering? Before you go down that probably red herring though, are there any events in the subforms that would interfere?
Adam Schwanz             
3 months ago
I figured it out, if you use the date picker to select the date, it seems to act like its lost the focus, I can get it to repeat what you're saying is happening with needing 2 clicks if I use the built-in date picker instead of typing in the value. Don't have any ideas off the top of my head on how to interact with that other than to say make your own datepicker calendar
Sami Shamma              
3 months ago
Now I am connected to my office computer through remote connection from home.
Everything in this form is vanilla.  There are no events running anywhere on this form.
All the data is preloaded on the main form and two sub forms. The only sub that is not preloaded is cancellations.
Sami Shamma              
3 months ago
Bingo. It is the goddamn date picker.  
I believe Richard has developed one somewhere, I'll find it.

Many thanks my friend
Sami Shamma              
3 months ago
Richard and Alex

Did you ever develop your own date picker?
I have the feeling that I've seen one on one of the videos!
Adam Schwanz             
3 months ago
I know theres one in the Access Calendar Seminar
Sami Shamma              
3 months ago
Thanks. I will look for it.
Adam Schwanz             
3 months ago
Theres THIS too
Sami Shamma              
3 months ago
Yes that's the one.
Funny, I couldn't find it in the search of the index
Kevin Yip       
3 months ago
This is probably better done with the form's BeforeUpdate event.  If the user tries to close the form without a proper entry, BeforeUpdate kicks in and prevents the UnLoad event from even running.
Sami Shamma              
3 months ago
Thank you, Kevin. I will try that.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in On Unload.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/13/2024 9:57:34 PM. PLT: 1s