Question about "x-ing" out of a form

webmeister

Definitely certifiable
Local time
Today, 14:15
Joined
Apr 6, 2006
Messages
107
When you have a form open, and then decide to "x-out" of the form by clicking on the "X" in the form's upper right-hand corner. Is there a way to grab, say, a text box's value and run some code against it before you actually "X-out" of the form?

What is the field name of that little "X" box on the form?

Thanks to any and all who reply.
 
Sure, you can use the Unload_Event. if after running your code you decide to cancel the close you can type Cancel=True
 
KeithG,

"Duh" to me re: the Unload_Event you suggested.

Not sure what you mean by "....if after running your code you decide to cancel the close you can type Cancel=True..." Can you explain in a bit more detail?

Thanks again!:D
 
If you go into the form module do you see the line Private Sub Form_Unload(Cancel As Integer)? Notice the parameter Cancel as Integer, if you type Cancel=True or Cancel=-1 then the form will not close but remain open.To show an example, say you have a field that must be filled in before closing the form, you could use the code below


if isNull(me.NameOfField)= true then
Msgbox("Please fill in required field")
Cancel=-1
End if
 
KeithG and GHudson,

Thanks for your replies and for your suggestions. They helped me tremendousy.

GHudson,
I tried doing a search on the forum, but did not know to search for the term, "Control Box X button." Also, I got slightly confused by what KeithG was trying to tell me, but his response straightened me out.

What I've been doing or at least attempting was to have a calendar form pop up when double-clicking on a date field on my main form, or when clicking on a calendar icon. Then....picking a date from the calendar form. If the date picked was different, I wanted an appointment in Outlook to get deleted and replaced by the appointment's new date. However, if the calendar was "X'ed out," then I wanted the original date to stay in the Outlook appointment calendar. In a nutshell.... open up my main form. Click / double-click my desired field. At that point, move the original date to a holding area, then delete the appointment. Next, if the new date chosen or entered was different, add that new appointment to my outlook calendar.

Believe it or not, it's almost working..... with your help and with a bit of coding luck, I should have it by tomorrow.

Thanks once again!
 

Users who are viewing this thread

Back
Top Bottom