ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Still Does Not Work (https://www.excelbanter.com/excel-programming/318920-code-still-does-not-work.html)

Minitman[_4_]

Code Still Does Not Work
 
Greetings,

I am trying to pass data from one UserForm to another and then hide
the first one. So far, I can get UserForm2 (UF2) to come up, but
UserForm1(UF1) doesn't hide until I cancel out of UF2. Then I must
use the button on the sheet that originally brought up UF1 to unhide
it. For some reason, the code that I use to bring up UF2 does not
finish running!!! I tried to do UF1.Show in the Cancel button on UF2
and I got an error that said I could not show what is not hidden(?).
So I removed it.

I then put MsgBoxes between each line to track what was happening.
It gets past the 1st MsgBox to open UF2 and no further, until I close
out UF2, then the rest of the Msg's pop up. This is also when UF1
gets hidden as the code progresses!!!!

Here is the code:

Private Sub CalculateButton_Click()

MsgBox "Bring up UF2"
UF2.Show
MsgBox "Hide UF1"
UF1.Hide
MsgBox "Copy the 1st amount"
UF2.T1.Text = UF1.TB16.Text
MsgBox "Copy the 2nd amount"
UF2.T2.Text = UF1.TB8.Text
MsgBox "Copy the 3rd amount"
UF2.T3.Text = UF1.TB7.Text
MsgBox "Copy the 4th amount"
UF2.T4.Text = Val(UF1.TB11.Text)
MsgBox "Copy the 5th amount"
UF2.T5.Text = UF1.TB9.Text
MsgBox "Copy the 6th amount"
UF2.T6.Text = UF1.TB13.Text
MsgBox "Copy the 7th amount"
UF2.T7.Text = UF1.TB15.Text
MsgBox "Copy the 8th amount"
UF2.T8.Text = UF1.TB10.Text
MsgBox "Copy the 9th amount"
UF2.T9.Text = UF1.TB12.Text
MsgBox "Copy the 10th amount"
UF2.T10.Text = UF1.TB14.Text
End Sub

Any help would be appreciated.

TIA

-Minitman

Sharad

Code Still Does Not Work
 

Hi,
If you hide the forms during run time, use the show method as below

UF1.Show vbModeless

UF2.Show vbModeless

You can then hide forms during run time. Also the code after above show
command will run. In case you don't use VbModeless option, the form can
not be hidden during run time, and the code will stop running after the
show command unless the user clicks buttons on the form to run the
corresponding code.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Minitman[_4_]

Code Still Does Not Work
 
Hey Sharad.

Thanks. It seems to be working much better, now.

I have another problem with percentage display and the way vba is
handling them, care to take a crack at this one? <G

TIA

-Minitman

On Mon, 13 Dec 2004 21:53:00 -0800, Sharad
wrote:


Hi,
If you hide the forms during run time, use the show method as below

UF1.Show vbModeless

UF2.Show vbModeless

You can then hide forms during run time. Also the code after above show
command will run. In case you don't use VbModeless option, the form can
not be hidden during run time, and the code will stop running after the
show command unless the user clicks buttons on the form to run the
corresponding code.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Bob Phillips[_6_]

Code Still Does Not Work
 
Now that's a challenge. Bring it on <vbg

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Minitman" wrote in message
...
Hey Sharad.

Thanks. It seems to be working much better, now.

I have another problem with percentage display and the way vba is
handling them, care to take a crack at this one? <G

TIA

-Minitman

On Mon, 13 Dec 2004 21:53:00 -0800, Sharad
wrote:


Hi,
If you hide the forms during run time, use the show method as below

UF1.Show vbModeless

UF2.Show vbModeless

You can then hide forms during run time. Also the code after above show
command will run. In case you don't use VbModeless option, the form can
not be hidden during run time, and the code will stop running after the
show command unless the user clicks buttons on the form to run the
corresponding code.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





Bob Phillips[_6_]

Code Still Does Not Work
 
Isn't it just the order that is wrong. If you use this order

Private Sub CalculateButton_Click()

MsgBox "Hide UF1"
UF1.Hide
MsgBox "Bring up UF2"
UF2.Show

form UF1 hides okay, UF2 becomes active and you can do all the biz. All of
the rest of the code should then be in the UF2 form, and you will need to
hide or unload it (UF2) after you have done all of that work, and show UF1
again .

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Minitman" wrote in message
...
Greetings,

I am trying to pass data from one UserForm to another and then hide
the first one. So far, I can get UserForm2 (UF2) to come up, but
UserForm1(UF1) doesn't hide until I cancel out of UF2. Then I must
use the button on the sheet that originally brought up UF1 to unhide
it. For some reason, the code that I use to bring up UF2 does not
finish running!!! I tried to do UF1.Show in the Cancel button on UF2
and I got an error that said I could not show what is not hidden(?).
So I removed it.

I then put MsgBoxes between each line to track what was happening.
It gets past the 1st MsgBox to open UF2 and no further, until I close
out UF2, then the rest of the Msg's pop up. This is also when UF1
gets hidden as the code progresses!!!!

Here is the code:

Private Sub CalculateButton_Click()

MsgBox "Bring up UF2"
UF2.Show
MsgBox "Hide UF1"
UF1.Hide
MsgBox "Copy the 1st amount"
UF2.T1.Text = UF1.TB16.Text
MsgBox "Copy the 2nd amount"
UF2.T2.Text = UF1.TB8.Text
MsgBox "Copy the 3rd amount"
UF2.T3.Text = UF1.TB7.Text
MsgBox "Copy the 4th amount"
UF2.T4.Text = Val(UF1.TB11.Text)
MsgBox "Copy the 5th amount"
UF2.T5.Text = UF1.TB9.Text
MsgBox "Copy the 6th amount"
UF2.T6.Text = UF1.TB13.Text
MsgBox "Copy the 7th amount"
UF2.T7.Text = UF1.TB15.Text
MsgBox "Copy the 8th amount"
UF2.T8.Text = UF1.TB10.Text
MsgBox "Copy the 9th amount"
UF2.T9.Text = UF1.TB12.Text
MsgBox "Copy the 10th amount"
UF2.T10.Text = UF1.TB14.Text
End Sub

Any help would be appreciated.

TIA

-Minitman




Minitman[_4_]

Code Still Does Not Work
 
Hey Bob,

Here's the deal, if I use formatting to convert a number to percent,
it make the number 100 time larger. The formatting that I am using is
this:
T4.Text = Format(T4.Text, "#0.00 %")
If T4 is .08 it shoes as 8.00 % and acts as 8.00 in formulas. I have
this formula:
T9.Text = Val(T4.Text) * Val(T8.Text)
I tried:
T9.Text = Val(T4.Text) * Val(T8.Text) * .01
But that does not seem to change the total.

Any ideas, thoughts or suggestions?

TIA

-Minitman




On Tue, 14 Dec 2004 10:33:31 -0000, "Bob Phillips"
wrote:

Now that's a challenge. Bring it on <vbg



Tom Ogilvy

Code Still Does Not Work
 
? val("8.00 %")
8
? val("8.00 %")*.01
0.08

I don't see how

T9.Text = Val(T4.Text) * Val(T8.Text)
T9.Text = Val(T4.Text) * Val(T8.Text) * .01


could give the same answer unless there was a zero in one of them.

--
Regards,
Tom Ogilvy


"Minitman" wrote in message
...
Hey Bob,

Here's the deal, if I use formatting to convert a number to percent,
it make the number 100 time larger. The formatting that I am using is
this:
T4.Text = Format(T4.Text, "#0.00 %")
If T4 is .08 it shoes as 8.00 % and acts as 8.00 in formulas. I have
this formula:
T9.Text = Val(T4.Text) * Val(T8.Text)
I tried:
T9.Text = Val(T4.Text) * Val(T8.Text) * .01
But that does not seem to change the total.

Any ideas, thoughts or suggestions?

TIA

-Minitman




On Tue, 14 Dec 2004 10:33:31 -0000, "Bob Phillips"
wrote:

Now that's a challenge. Bring it on <vbg





Minitman[_4_]

Code Still Does Not Work
 
Hey Bob,

Thanks for the reply.

I ended up with something similar, I moved all but the loading of UF2
to the UserForm_Initialize() on UF2. So you were right, as usual, it
was the order. <GBG (is that a "Great Britain Grin?)

-Minitman


On Tue, 14 Dec 2004 10:42:01 -0000, "Bob Phillips"
wrote:

Isn't it just the order that is wrong. If you use this order

Private Sub CalculateButton_Click()

MsgBox "Hide UF1"
UF1.Hide
MsgBox "Bring up UF2"
UF2.Show

form UF1 hides okay, UF2 becomes active and you can do all the biz. All of
the rest of the code should then be in the UF2 form, and you will need to
hide or unload it (UF2) after you have done all of that work, and show UF1
again .



Minitman[_4_]

Code Still Does Not Work
 
Hey Tom,

Thanks for the reply.

Opps!!!
When I went to bed last night, it was messing up as mentioned. I just
rechecked it and now it is working. Sorry for the confusion. I must
have been more tired than I realized. <g

-Minitman

On Tue, 14 Dec 2004 09:14:18 -0500, "Tom Ogilvy"
wrote:

? val("8.00 %")
8
? val("8.00 %")*.01
0.08

I don't see how

T9.Text = Val(T4.Text) * Val(T8.Text)
T9.Text = Val(T4.Text) * Val(T8.Text) * .01


could give the same answer unless there was a zero in one of them.




All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com