Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vba combo box 1

Status
Not open for further replies.

bobbyz24

Programmer
Oct 8, 2010
4
CA
hi,

I am in need of help... I have a combo box and in the drop down will be the choices of the number 1-10(1,2,3,..etc), now I have a function that states if combo box is left by the user then a msgbox displays saying "please select a choice"...

how can I modify this to say that if they dont select an option or if they dont choose one of the listed choices (1,2,etc) then a msgbox will display...

or can I lock the combo box so they can only select a choice?

do I include an AND to my if.. or else if, or

thank you,

bob
 


Hi,

What application?

What kind of control, as Excel, for instance, has 3 different kinds of "combo boxes", and Word has 2?

Please be as specific as possible and please answer each of these questions.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
hey,

oops...

this is in Word 2007, and I only know of one kind of combo box(drop down), I only know of one...

bob
 


There is a Forms drop down and an ActiveX drop down.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
hi,

ahh, ok, I got it...

its a forms drop down... I am creating a form

bob
 



You could make all other controls unavailable until the combo has a valid selection.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
hmmm,

I am not sure how to do that...

I guess I was thinking there was a way to say

if 1,2,3...etc are not selected, msgbox...

-because now if you just type in the combo field... I am trying to make it so they are either forced to pick an option or at least if they do try and type something in, they will receive an error... (msgbox)
b
 



Forced? Do you have a gun?

How will a message box force them to do anything?

Either you have some sort of SUBMIT process that checks each possible user entry of you lead them thru the wickets, one step at a time.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

Why not choose the first 'option' for the user?
Code:
Dim i As Integer

For i = 1 To 10
    ComboBox1.AddItem i
Next i
[blue]
ComboBox1.ListIndex = 0[/blue]

Have fun.

---- Andy
 
ComboBox1.AddItem is not valid - if this is indeed a formfield, rather than an ActiveX.

bobbyz24, we need to be certain what it is you are working with. Unfortunately stating

"its a forms drop down... I am creating a form"

is not enough. The word "form" is not well used. It could still be a formfield OR an ActiveX.

Please describe exactly the steps you took to get the "dropdown" into the document. And, did you have to Protect the document for forms in order to get the dropdown to work? What happens if you right-click the dropdown?

If it IS a formfield, then the user can not enter anything. They must select a dropdown item (or of course not do anything at all).

Which makes me think it is an ActiveX. If it IS an ActiveX then you must have a procedure (some code) that populates the control with the dropdown items. Do you?


unknown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top