Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Form Unload?

I have a userform with this command button to exit. When user enters data
in form that data will be added to worksheet. When user clicks on this exit
button (cmd button 3) I get a message if you want to save form. I do not
want user to save form at all. I just want to unload form. How can I
suppress this? I just want to unload and not save form. I tried the
following but not working: Userform2 savechanges: = false; Userform2.close
save changes: = false. But it does not work. Can this be done?


Private Sub CommandButton3_Click()

If MsgBox("Do you want to Exit?", vbOKCancel, "Exit or Cancel??") = vbOK Then
'whatever you want to do
ActiveWorkbook.Close 'closes the workbook
Unload Me 'closes the form


End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Form Unload?

Try Application.DisplayAlerts = False

"TotallyConfused" wrote:

I have a userform with this command button to exit. When user enters data
in form that data will be added to worksheet. When user clicks on this exit
button (cmd button 3) I get a message if you want to save form. I do not
want user to save form at all. I just want to unload form. How can I
suppress this? I just want to unload and not save form. I tried the
following but not working: Userform2 savechanges: = false; Userform2.close
save changes: = false. But it does not work. Can this be done?


Private Sub CommandButton3_Click()

If MsgBox("Do you want to Exit?", vbOKCancel, "Exit or Cancel??") = vbOK Then
'whatever you want to do
ActiveWorkbook.Close 'closes the workbook
Unload Me 'closes the form


End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Form Unload?

you're closing the activeworkbook - so thats where the data from the userform
was saved to...so it would be odd NOT to save the workbook. Why load data to
it then close without saving?
anyway

yuou could change this line
ActiveWorkbook.Close 'closes the workbook
to either
ActiveWorkbook.Close TRUE 'closes the workbook
or
ActiveWorkbook.Close FALSE'closes the workbook

to close and save or close without saving


"TotallyConfused" wrote:

I have a userform with this command button to exit. When user enters data
in form that data will be added to worksheet. When user clicks on this exit
button (cmd button 3) I get a message if you want to save form. I do not
want user to save form at all. I just want to unload form. How can I
suppress this? I just want to unload and not save form. I tried the
following but not working: Userform2 savechanges: = false; Userform2.close
save changes: = false. But it does not work. Can this be done?


Private Sub CommandButton3_Click()

If MsgBox("Do you want to Exit?", vbOKCancel, "Exit or Cancel??") = vbOK Then
'whatever you want to do
ActiveWorkbook.Close 'closes the workbook
Unload Me 'closes the form


End If

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to unload a form Grd Excel Programming 3 March 20th 07 03:48 PM
Unload User Form Partho[_3_] Excel Programming 4 October 17th 06 04:21 AM
Unload the form on esc key Papou Excel Programming 0 August 10th 04 05:15 PM
form won't unload inquirer Excel Programming 1 May 26th 04 09:55 AM
Form Unload Khai[_2_] Excel Programming 0 August 4th 03 09:28 PM


All times are GMT +1. The time now is 08:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"