A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded?



 
 
Thread Tools Display Modes
  #1  
Old December 4th 03, 03:54 PM posted to microsoft.public.excel.programming
Luisa[_2_]
external usenet poster
 
Posts: 2
Default 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
Ads
  #2  
Old December 4th 03, 04:04 PM posted to microsoft.public.excel.programming
Tom Ogilvy
external usenet poster
 
Posts: 27,285
Default 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  
Old December 5th 03, 08:15 AM posted to microsoft.public.excel.programming
Luisa[_2_]
external usenet poster
 
Posts: 2
Default 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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert 29.08 hours (shown in decimal form) to time shown in "hh:m Nila in Florida Excel Worksheet Functions 1 September 14th 08 01:35 AM
Column of Text Shown = Total Times Shown? philcassell Excel Worksheet Functions 3 July 19th 06 07:24 AM
Named Ranges shown (or not shown) as blue means what? wdeleo Excel Worksheet Functions 0 July 8th 05 01:40 PM
listbox value not initialized John Holland Excel Programming 2 November 25th 03 07:57 PM
Detecting if a userform is loaded Seth[_5_] Excel Programming 2 November 4th 03 02:59 AM


All times are GMT +1. The time now is 05:41 PM.


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