VBA Click option on a Combobox to another userform

MFish

Board Regular
Joined
May 9, 2019
Messages
74
Hi,

What I'm trying to complete is this -
I have a combobox1 that has data, "1-1", "1-2", etc. and within this same user form (userform1) there is 3 different option buttons to choose from.
I want to write a code that executes this...

I want to show userform2 when I choose optionbutton1, no matter the selection of combobox data, 1-1, 1-2, etc.
Show userform2 when I choose optionbutton2, "..."
Show userform3 when I choose optionbutton3, "..."

Please note I want this action to happen AFTER I have selected data in the combobox, not when I click on the optionbutton1. Possible?

Now, my question to you beyond this... If I want to build a multi-layer "Open this form", to "Open that form" will my existing form "save" the information before moving on?
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
Please define what you mean by "Save"? As long as you simply hide it, the form selections will remain unchanged and you will be able to reference the information by control. (ie: myVar = userform.label.caption). If the form is unloaded then no, it will drop any information; You will want to pass your values from the form before you unload it to the next form as you load it up.
 
Last edited:

MFish

Board Regular
Joined
May 9, 2019
Messages
74
Please define what you mean by "Save"? As long as you simply hide it, the form selections will remain unchanged and you will be able to reference the information by control. (ie: myVar = userform.label.caption). If the form is unloaded then no, it will drop any information; You will want to pass your values from the form before you unload it to the next form as you load it up.
Hi Steve_,

Thanks for your response. I've been noticing it does "Save" the information on the past userform before opening the next userform. I don't have a code that unloads anything, besides a commandbutton2 that's a clear function.
I have figured out my question, above, with showing an additional userform off a selection in a combobox and/or optionbutton. Was playing around with it and figured it out. Now, I have a follow up question...
After I fill out a userform and hit submit and it brings up the previous userform... Is it possible to pull the data from the second userform onto the first one? I just need a way for the textbox to reference a certain userform, within the workbook, to pull the data from.
Code:
sub textbox1()

if textbox1.value (within userform2 - Don't know how to reference another userform) = "" then textbox1.value = ""
end if
if textbox1.value (within userform2) = "*" then textbox1.value = "*"
end if
end sub
What I'm trying to accomplish... I want the textbox to copy the information from another textbox on ANOTHER userform.
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
Fully qualify your textboxes when you reference them.

sub textbox1()

if USERFORM2.textbox1.value = "" then USERFORM1.textbox1.value = ""
'(You do not need to use end if when your if/then statement is only one line.)

if USERFORM2.textbox1.value = "*" then
USERFORM1.textbox1.value = "*"
end if '(This is when end if is needed. See how my If/Then are multiple lines?)
end sub
 
Last edited:

MFish

Board Regular
Joined
May 9, 2019
Messages
74
Thanks Steve,

Now, as long as all of my Userforms are named uniquely, then any of my textboxes will know which one to pull information from? No matter how many userforms I may have?
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
As long as you fully qualify the textboxes when you refer to them, yes. userformName.controlName.propertyDesired. (Ie: UserForm1.Textbox1.Text)
 
Last edited:

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,743
Office Version
2013
Platform
Windows
I see you have been asking a lot of questions about UserForms lately.
I do not mean to be too noisy but would you care to explain what your ultimate Goal here is.

I have been using UserForms for years and never needed more then one to perform a task or more then one task.

Have you ever used UserForm Multipages ?

A UserForm Multipage is like have numerous UserForms all in the same UserForm

Like having one Workbook with many Worksheets.

If you would like to know more about UserForm Multipages let me know and I will explain more.

A lot easier in my opinion then needing numerous UserForms.
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
and also, depending on what you are doing, i normally prefer not to use any prebuilt forms at all, opting to programmatically draw and destroy my forms on the fly as needed.
I was forced to do this for a few of my projects, like my "Excel Fantasy" game I wrote (Think Final Fantasy from NES/SNES, only written in excel) which simply was too unstable with all the forms/multipages I had to use.

this is likely not a solution you are looking for though.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,095,971
Messages
5,447,613
Members
405,458
Latest member
newbie111

This Week's Hot Topics

Top