Form Unload?

  • Thread starter TotallyConfused
  • Start date
T

TotallyConfused

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
 
P

Patrick Molloy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top