Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2020, 06:23 PM
4Star1957 4Star1957 is offline Combo Box/List Box (using IF commands?) Windows 10 Combo Box/List Box (using IF commands?) Office 2016
Novice
Combo Box/List Box (using IF commands?)
 
Join Date: Sep 2020
Posts: 12
4Star1957 is on a distinguished road
Default Combo Box/List Box (using IF commands?)

Hello, I have 6 userforms each of them have different variables for a template. I would like for the user to open the template and select via a combo box (on a userform) the template type they require when the template is selected via the combo box I would like for the userform containing all the variables to appear. Not sure whether I'd use a combo box or list box? Apologies if isn't clear my knowledge is basic.
Reply With Quote
  #2  
Old 09-19-2020, 06:47 PM
Guessed's Avatar
Guessed Guessed is offline Combo Box/List Box (using IF commands?) Windows 10 Combo Box/List Box (using IF commands?) Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Either a Combo Box or a List box would work. A combobox implies a choice of only one can be made. A Listbox implies that one or more can be chosen and it only takes a single click to change between choices.

I would make the template type a combo box. And the available variables a list box. If you set the listbox to have multiple columns then it can also store the values assigned to each variable. Then code it so that you can click on a variable and type into a nearby Textbox to create/edit the value assigned to that variable.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 09-19-2020, 07:59 PM
4Star1957 4Star1957 is offline Combo Box/List Box (using IF commands?) Windows 10 Combo Box/List Box (using IF commands?) Office 2016
Novice
Combo Box/List Box (using IF commands?)
 
Join Date: Sep 2020
Posts: 12
4Star1957 is on a distinguished road
Default

Hi Guessed thank you for your reply. I will attempt to use the combobox - only one selection will be required. The selections will be the type of contract ie either "full time", "part time" or "casual". I have set up docvariables in a template. I have also set up 3 userforms each containing the variables required for the type of employment. The user will open the template and a userform is presented with a combobox where they select the type of employment... then I want to call the correct userform. I know that I will need to hide and show userforms, I know of the code to do that. I also know the basic code to set up a combobox. What I'm not sure of is how to layout the code.

If combobox1.value = full time Then
I know here I'm to hide the current userform and show the next one
but I'm not sure of how the code should be set out.

I have started this project using multitab userform - but it more than likely will get too big - because there could actually be 6 different types of employment.

This is the code I have behind the combobox.

Sub ComboBox1_Change()
With ComboBox1
.AddItem "Maximum Term Full Time"
.AddItem "Maximum Term Part Time"
.ListIndex = 0
End With

If ComboBox1.Value = "Maximum Term Full Time" Then
UForm1.Hide
UForm2.Show
End If
If ComboBox1.Value = "Maximum Term Part time" Then
UForm1.Hide
UForm3.Show
End If

End Sub

I am hoping you give me some advice as to how to set this up so it works. Currently when I run this code it shows the userform - but there is nothing in it.

Last edited by 4Star1957; 09-19-2020 at 08:28 PM. Reason: Wanted to show the code I tried - but it does not work.
Reply With Quote
  #4  
Old 09-19-2020, 08:46 PM
Guessed's Avatar
Guessed Guessed is offline Combo Box/List Box (using IF commands?) Windows 10 Combo Box/List Box (using IF commands?) Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not a fan of doing work to re-create what I think you have in order to show you something that may or may not match. Please post a sample doc that shows your current code.

In the case of the code you have posted, the Change event on ComboBox1 shouldn't start by adding more values into the list of that same control and then changing the value of to the first item (which causes the same event to run). Doesn't this seem like an infinite loop to you?

It is generally poor practice to show a list and then when you user makes a selection from that list, suddenly add another couple of options to the list and change the selection to the original first item in the list.

You don't need multiple forms, a single form should do everything you need. Having multiple forms just forces you to reproduce and manage the same code in lots of different places.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 09-19-2020, 08:50 PM
4Star1957 4Star1957 is offline Combo Box/List Box (using IF commands?) Windows 10 Combo Box/List Box (using IF commands?) Office 2016
Novice
Combo Box/List Box (using IF commands?)
 
Join Date: Sep 2020
Posts: 12
4Star1957 is on a distinguished road
Default Thank you for your help.

Thank you for your help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box/List Box (using IF commands?) Changing Drop Down List to Combo Box workingspade Word 6 09-09-2022 06:12 AM
Combo Box/List Box (using IF commands?) Take an Excel List and Add to Word Combo Box dlafko1 Word VBA 9 04-12-2019 06:24 AM
Letter Template /w combo box list etruz Word 4 10-31-2018 05:16 AM
Format Font Size in Combo Box List lukewarmbeer Word VBA 0 08-27-2011 07:28 AM
Bold list items in a combo box DrewB Word VBA 0 07-17-2009 11:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:36 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft