|
-
Feb 9th, 2005, 10:09 AM
#1
Thread Starter
Frenzied Member
Close or Unload
Which event is the best place to put code that should be run when the user closes a form? I have code in the Unload event of a form that is supposed to send an email and delete all data from a table. It's always worked for two users, but not for a new user. I'm not sure what she did differently. The way they close the form is to click the x button in the control box.
Is there a reason the code should be in the close event rather than the unload event? I've typically used the close event just to check if the user really wants to close the form.
Thanks.
Tengo mas preguntas que contestas
-
Feb 9th, 2005, 12:30 PM
#2
Re: Close or Unload
The Form_Unload event would be the better event to trap for canceling of
the form from unloading if a user wants to change their mind.
The Close event occurs after the Unload event, which is triggered after the form is closed but before it is
removed from the screen. When you close a form, the following events occur in this order:
Unload → Deactivate → Close
When the Close event occurs, you can open another window or request the user's name to make a log entry
indicating who used the form or report.
The Unload event can be canceled, but the Close event can't.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 9th, 2005, 01:13 PM
#3
Thread Starter
Frenzied Member
Re: Close or Unload
Ok, thanks, I guess I got the verifying the close mixed up. Haven't actually checked for that in a long time.
But in the code below, ClearTempLog is a sub that deletes all data from the TempLog table, and it didn't run. That's what I can't figure out.
VB Code:
If MsgBox("Are you finished editing the " & mstrDbName & " comments?", vbYesNo + vbQuestion, "Editing Complete?") = vbYes Then
DoCmd.SendObject acSendTable, mstrLogName, acFormatTXT, "Boss", , , mstrDbName & _
" Editor Changes", mstrDbName & " changes attached.", True
ClearTempLog
End If
Tengo mas preguntas que contestas
-
Feb 9th, 2005, 01:28 PM
#4
Re: Close or Unload
Place a breakpoint at the If MsgBox line. Then run your form and close it answering it with yes. Step
through and see where the code execution is going. Is it evaluating the vbYes? Is it going into the
ClearTempLog procedure but generating an error so it jumps out of that procd?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|