Excel Userform

F

fi.or.jp.de

Hi All,

In my excel, i have two userforms.

I have used code like this..
Problem is when i unload userform1 and load userform2, the userform2
is not visible until i click excel file.
I dont need to click excel file to activate userform2, how can i do
this automatically.

Userform1.show

Do...... something....


Unload Userform1

Userform2.show

do.. somethinng

unload userform2
 
G

GS

fi.or.jp.de pretended :
Hi All,

In my excel, i have two userforms.

I have used code like this..
Problem is when i unload userform1 and load userform2, the userform2
is not visible until i click excel file.
I dont need to click excel file to activate userform2, how can i do
this automatically.

Userform1.show

Do...... something....


Unload Userform1

Userform2.show

do.. somethinng

unload userform2

In order to have your code continue to run while your userforms are
open you need to specify...

Userform1.Show vbModeless
'Do stuff while userform is open
Unload Userform1

I assume your users do not do anything with the userform other than
watch what your code does.

What stops users from closing it themselves?
What are you doing in your code while the userform is displayed?
How does the userform update while code is running?
 
F

fi.or.jp.de

First userform1 gives option to input username and password
once it logs into the system automatically close the userform1

and userform2 loads - shows the progress of the macro or the work
done.

Once the userform1 unloads userform2 is not visible , I need to click
on excel......
 
G

GS

fi.or.jp.de brought next idea :
First userform1 gives option to input username and password
once it logs into the system automatically close the userform1

and userform2 loads - shows the progress of the macro or the work
done.

Once the userform1 unloads userform2 is not visible , I need to click
on excel......

Okay, it sounds like you're using the login userform to show a progress
bar. If this is the case then your code needs to be something like
this:

Sub DoStuff()
fUserLogin.Show
If Not fProgress Is Nothing Then
'do whatever needs fProgress displayed
Unload fProgress
End If
End Sub

On fUserLogin, include an OK button that when clicked it validates the
login. If (and only if) the login validates then include code to open
fProgress vbModeless and unload the login form something like this:

Sub cmdOK_Click()
If bValidateUserLogin Then fProgress.Show vbModeless
Unload Me
End Sub

...where bValidateUserLogin is the function that returns the result of
login validation as a boolean value (true or false). So.., if login is
successful then fProgress displays because your function will return a
value of TRUE.

If bValidateUserLogin returns false then fProgress isn't opened, and
your DoStuff routine will need to know how to handle that. In this case
it checks to see if fProgress is open before attempting to do anything
and then close it. The code example doesn't let the code execute unless
fProgress is open, meaning user login was validated.

So to sum up the changes needed, Userform1 should control its own
unloading and whether Userform2 is displayed. Your procedure should
display Userform1 and execute code then unload Userform2 only if it's
loaded.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top