Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded?
I have a Userform1 where the user can select between different
transactions. If the Clientbutton is clicked I hide Userform1 and show Userform2, opens an excel workbook and enters some values. If the Exitbutton on Userform2 is clicked I unload Userform2 and in the terminate event I save the workbook and show Userform1 again. So far so good ... it works fine ... the problem is when I then click the Clientbutton on Userform1 a second time. Userform2 is shown alright, but the workbook is not opened and I cannot click neither the Exitbutton nor the Close (X in upper right corner) ... only solution is CTRL+ALT+DELETE. Any solutions? Regards, Luisa Code on Userform1: Private Sub ClientButton_Click() UserForm1.Hide UserForm2.Show End Sub Code on Userform2: Private Sub ExitButton_Click() Unload UserForm2 End Sub Private Sub UserForm_initialize() ClientFile = ActiveWorkbook.Path & "\Client.xls" Workbooks.Open Filename:=ClientFile End Sub Private Sub UserForm_Terminate() ActiveWorkbook.Close SaveChanges:=True UserForm1.Show End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded?
The terminate event for userform2 is suspended waiting the closing of
userform1. You should manage your userforms from a single routine, passing back information that the routine uses to make a decision on whether to show another userform or to quit (or do something else). -- Regards, Tom Ogilvy "Luisa" wrote in message om... I have a Userform1 where the user can select between different transactions. If the Clientbutton is clicked I hide Userform1 and show Userform2, opens an excel workbook and enters some values. If the Exitbutton on Userform2 is clicked I unload Userform2 and in the terminate event I save the workbook and show Userform1 again. So far so good ... it works fine ... the problem is when I then click the Clientbutton on Userform1 a second time. Userform2 is shown alright, but the workbook is not opened and I cannot click neither the Exitbutton nor the Close (X in upper right corner) ... only solution is CTRL+ALT+DELETE. Any solutions? Regards, Luisa Code on Userform1: Private Sub ClientButton_Click() UserForm1.Hide UserForm2.Show End Sub Code on Userform2: Private Sub ExitButton_Click() Unload UserForm2 End Sub Private Sub UserForm_initialize() ClientFile = ActiveWorkbook.Path & "\Client.xls" Workbooks.Open Filename:=ClientFile End Sub Private Sub UserForm_Terminate() ActiveWorkbook.Close SaveChanges:=True UserForm1.Show End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded?
Hi Tom,
Sorry, but I don't understand (being a newbie with forms) ... the code in the terminate event is executed, i.e. the workbook is closed, the changes are saved and Userform2 is shown ... so what do you mean by the "terminate event is suspended"? Do the terminate event not finish up? Regards, Luisa "Tom Ogilvy" wrote in message ... The terminate event for userform2 is suspended waiting the closing of userform1. You should manage your userforms from a single routine, passing back information that the routine uses to make a decision on whether to show another userform or to quit (or do something else). -- Regards, Tom Ogilvy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert 29.08 hours (shown in decimal form) to time shown in "hh:m | Excel Worksheet Functions | |||
Column of Text Shown = Total Times Shown? | Excel Worksheet Functions | |||
Named Ranges shown (or not shown) as blue means what? | Excel Worksheet Functions | |||
listbox value not initialized | Excel Programming | |||
Detecting if a userform is loaded | Excel Programming |