Code Still Does Not Work

  • Thread starter Thread starter Minitman
  • Start date Start date
M

Minitman

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
 
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
 
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
 
Now that's a challenge. Bring it on <vbg>

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
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)
 
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
 
? 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.
 
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
 
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
 
Back
Top