![]() |
Form Actions
Hi,
I have 2 forms on the first form is a button which saves the current work book, unloads the form and then opens the second form. The problem is when I click the first button the form does not shut and the second one opens over the top and when you click the button on the second form to shut it the whole thing crash's can someone help, here is code I am using Button One Private Sub Finnish_Click() ActiveWorkbook.Save ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" Unload Me UserForm3.Show End Sub Button Two Private Sub UserForm_Click() Unload Me End Sub Thanks |
Form Actions
Hide the userform before opening the 2nd userform. You don't need the unload.
"Phil" wrote: Hi, I have 2 forms on the first form is a button which saves the current work book, unloads the form and then opens the second form. The problem is when I click the first button the form does not shut and the second one opens over the top and when you click the button on the second form to shut it the whole thing crash's can someone help, here is code I am using Button One Private Sub Finnish_Click() ActiveWorkbook.Save ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" Unload Me UserForm3.Show End Sub Button Two Private Sub UserForm_Click() Unload Me End Sub Thanks |
Form Actions
Hi Joel,
Thanks for the reply, I have tried what you suggested but am still getting the same problem, any other thoughts?? Thanks "Joel" wrote: Hide the userform before opening the 2nd userform. You don't need the unload. "Phil" wrote: Hi, I have 2 forms on the first form is a button which saves the current work book, unloads the form and then opens the second form. The problem is when I click the first button the form does not shut and the second one opens over the top and when you click the button on the second form to shut it the whole thing crash's can someone help, here is code I am using Button One Private Sub Finnish_Click() ActiveWorkbook.Save ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" Unload Me UserForm3.Show End Sub Button Two Private Sub UserForm_Click() Unload Me End Sub Thanks |
Form Actions
I thought this would work
Private Sub Finnish_Click() ActiveWorkbook.Save ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" Userform2.Hide UserForm3.Show End Sub Button Two Private Sub UserForm_Click() msgbox("Put some code here to stop userform three from immediately shutting down") Userform3.Unload End Sub "Phil" wrote: Hi Joel, Thanks for the reply, I have tried what you suggested but am still getting the same problem, any other thoughts?? Thanks "Joel" wrote: Hide the userform before opening the 2nd userform. You don't need the unload. "Phil" wrote: Hi, I have 2 forms on the first form is a button which saves the current work book, unloads the form and then opens the second form. The problem is when I click the first button the form does not shut and the second one opens over the top and when you click the button on the second form to shut it the whole thing crash's can someone help, here is code I am using Button One Private Sub Finnish_Click() ActiveWorkbook.Save ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" Unload Me UserForm3.Show End Sub Button Two Private Sub UserForm_Click() Unload Me End Sub Thanks |
Form Actions
Create a new sub in a standard module that shows the second form:
Sub OpenSecondForm() UserForm3.Show End Sub Back in Sub Finnish_Click replace: UserForm3.Show with Application.OnTime Now, "OpenSecondForm" -- Jim "Phil" wrote in message ... | Hi Joel, | | Thanks for the reply, I have tried what you suggested but am still getting | the same problem, any other thoughts?? | | Thanks | | | "Joel" wrote: | | Hide the userform before opening the 2nd userform. You don't need the unload. | | "Phil" wrote: | | Hi, | | I have 2 forms on the first form is a button which saves the current work | book, unloads the form and then opens the second form. The problem is when I | click the first button the form does not shut and the second one opens over | the top and when you click the button on the second form to shut it the whole | thing crash's can someone help, here is code I am using | | Button One | | Private Sub Finnish_Click() | ActiveWorkbook.Save | ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" | Unload Me | UserForm3.Show | End Sub | | Button Two | | Private Sub UserForm_Click() | | Unload Me | End Sub | | | Thanks |
Form Actions
Hi Jim,
Thanks for the reply, that worked brilliantly, Dont suppose you can tell me why they way that I was doing it wasn't working, just like to know for next time. Thanks Phil "Jim Rech" wrote: Create a new sub in a standard module that shows the second form: Sub OpenSecondForm() UserForm3.Show End Sub Back in Sub Finnish_Click replace: UserForm3.Show with Application.OnTime Now, "OpenSecondForm" -- Jim "Phil" wrote in message ... | Hi Joel, | | Thanks for the reply, I have tried what you suggested but am still getting | the same problem, any other thoughts?? | | Thanks | | | "Joel" wrote: | | Hide the userform before opening the 2nd userform. You don't need the unload. | | "Phil" wrote: | | Hi, | | I have 2 forms on the first form is a button which saves the current work | book, unloads the form and then opens the second form. The problem is when I | click the first button the form does not shut and the second one opens over | the top and when you click the button on the second form to shut it the whole | thing crash's can someone help, here is code I am using | | Button One | | Private Sub Finnish_Click() | ActiveWorkbook.Save | ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" | Unload Me | UserForm3.Show | End Sub | | Button Two | | Private Sub UserForm_Click() | | Unload Me | End Sub | | | Thanks |
Form Actions
Well, the problem is that when you unload a userform in a sub it doesn't
really unload until that sub is done running. And since that sub opened another userform that sub is not done until the second form is closed. It can get messy. Using OnTime breaks the connection because it allows the sub with the unload to complete before the code that opens the second form is run. -- Jim "Phil" wrote in message ... | Hi Jim, | | Thanks for the reply, that worked brilliantly, | | Dont suppose you can tell me why they way that I was doing it wasn't | working, just like to know for next time. | | Thanks Phil | | "Jim Rech" wrote: | | Create a new sub in a standard module that shows the second form: | | Sub OpenSecondForm() | UserForm3.Show | End Sub | | Back in Sub Finnish_Click replace: | | UserForm3.Show | | with | | Application.OnTime Now, "OpenSecondForm" | | -- | Jim | "Phil" wrote in message | ... | | Hi Joel, | | | | Thanks for the reply, I have tried what you suggested but am still getting | | the same problem, any other thoughts?? | | | | Thanks | | | | | | "Joel" wrote: | | | | Hide the userform before opening the 2nd userform. You don't need the | unload. | | | | "Phil" wrote: | | | | Hi, | | | | I have 2 forms on the first form is a button which saves the current | work | | book, unloads the form and then opens the second form. The problem is | when I | | click the first button the form does not shut and the second one opens | over | | the top and when you click the button on the second form to shut it | the whole | | thing crash's can someone help, here is code I am using | | | | Button One | | | | Private Sub Finnish_Click() | | ActiveWorkbook.Save | | ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" | | Unload Me | | UserForm3.Show | | End Sub | | | | Button Two | | | | Private Sub UserForm_Click() | | | | Unload Me | | End Sub | | | | | | Thanks | | | |
Form Actions
Thanks for that Jim, its much appreciated I am sure its not going to be the
last time that I have to do something like this. Thanks PD "Jim Rech" wrote: Well, the problem is that when you unload a userform in a sub it doesn't really unload until that sub is done running. And since that sub opened another userform that sub is not done until the second form is closed. It can get messy. Using OnTime breaks the connection because it allows the sub with the unload to complete before the code that opens the second form is run. -- Jim "Phil" wrote in message ... | Hi Jim, | | Thanks for the reply, that worked brilliantly, | | Dont suppose you can tell me why they way that I was doing it wasn't | working, just like to know for next time. | | Thanks Phil | | "Jim Rech" wrote: | | Create a new sub in a standard module that shows the second form: | | Sub OpenSecondForm() | UserForm3.Show | End Sub | | Back in Sub Finnish_Click replace: | | UserForm3.Show | | with | | Application.OnTime Now, "OpenSecondForm" | | -- | Jim | "Phil" wrote in message | ... | | Hi Joel, | | | | Thanks for the reply, I have tried what you suggested but am still getting | | the same problem, any other thoughts?? | | | | Thanks | | | | | | "Joel" wrote: | | | | Hide the userform before opening the 2nd userform. You don't need the | unload. | | | | "Phil" wrote: | | | | Hi, | | | | I have 2 forms on the first form is a button which saves the current | work | | book, unloads the form and then opens the second form. The problem is | when I | | click the first button the form does not shut and the second one opens | over | | the top and when you click the button on the second form to shut it | the whole | | thing crash's can someone help, here is code I am using | | | | Button One | | | | Private Sub Finnish_Click() | | ActiveWorkbook.Save | | ActiveWorkbook.SaveAs Filename:="C:\Questionaire.xls" | | Unload Me | | UserForm3.Show | | End Sub | | | | Button Two | | | | Private Sub UserForm_Click() | | | | Unload Me | | End Sub | | | | | | Thanks | | | |
All times are GMT +1. The time now is 05:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com