PDA

View Full Version : Solved: unloading linked userforms



lehgzil
10-04-2010, 08:07 PM
gud day/evening to everyone again,

now i switched focused to userforms, what i am doing right now is linking userforms with basic controls inside, what i have is 3 userforms on which when the 1st was filled the user clicks NEXT button and then goes to 2nd then again on 3rd. 2nd and 3rd userforms has a BACK button on which loads the previous userforms(if 3rd back then show 2nd, 2nd then show 1st)
well my code do pretty well on that.
i use unload Me for back button and Userform.show on Next button.

yet my problem is on the third userform on which i have the ok button which should closes/unloads all the userforms.

i have a work around on which the ok button is on the 1st userform and that the last userform is linked to the 1st but still that slows the processing.

what ive tried

Private Sub cmdOK_Click()
'Unload the userform
Dim u1 As UserForm
Dim u2 As UserForm
Dim u3 As Userform
u1 = UserForm1
u2 = UserForm2
u3 = Userform3
Unload u1
Unload u2
Unload u3
End sub


and

Private Sub cmdOK_Click()
'Unload the userform
Unload UserForm1
Unload UserForm2
Unload Userform3
end sub
and i got errors on those, any suggestions?

Jan Karel Pieterse
10-05-2010, 12:45 AM
Sounds as if you're creating some sort of a wizard.

You can make your life considerably simpler by having only ONE userform, which makes use of a multipage control. The Previous/Next buttons (located outside of the multpipage) then only need to change the Value of the multipage to have your wizard show a new "page".
You can get rid of the tabs of the multipage, by setting the multipage's Style property to 2 - fmTabStlyeNone.

lehgzil
10-05-2010, 02:08 AM
yes im creating some thing like that.
uhm, i dunno still how to create a multi page userform though, but i get your point.
but it seems i think my tools for my vba doesnt support the idea like in vb or vb.net.
would multi "frame" control showing and unshowing would do? like frame1.show, frame1.hide?
thanks for the idea sir jkpieterse
ill get back to this tomorrow,
anymore ideas will help, thanks

Jan Karel Pieterse
10-08-2010, 12:46 AM
Yes, you could use frames as well, but a multipage is simpler to design.

With frames, -at design time- you would have to make the userform window large enough to be able to draw all frames next to/below each other. At runtime, you have to resize the userform and then when you want to show one of the frames, it has to be positioned properly and made visible. Not hard to do, simply more work than a multipage.

In case you use the MP, -at design time- you position the MP and then design each page in turn. The form can be a fixed size. At runtime, you just change the MP's value to "turn the page".

Bob Phillips
10-08-2010, 03:46 AM
I support Jan Karel's view. Multipage is good, it shows them where they have reached in the wizard progress, and it makes going back very simple as well.

lehgzil
10-12-2010, 11:39 PM
ok done now, thanks for the advices sir jan karel and xld...
that did it much simpler...

my projects almost done now, but still somethings going wrong as of my other post - "file path/access error always"