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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datacombo get value 3

Status
Not open for further replies.

seema165

Programmer
Jul 11, 2005
48
GB
Hi,

This is my first thread!
I have a datacombo dropdown. I choose an option from the dropdown. I then want to do an if statement saying that if the datacombo selected value is not null do something.

How would I write this?
Is it If Len(Trim$(dataCombo.BoundText)) = 0 Then ...


Please help with this as it is urgent.
Thanks in advance for any help!
 
Do you mean if they have selected something, or do you mean that there is/are null options in the combo and you want to make sure they haven't selected one of those? If the former, just check that listIndex > -1.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi tsdragon,

What I mean is if you have selected something in the datacombo, then I need to say if the selection is not null then do ....

There are no null options in the combo.

 
If there are no NULL options in the combo then why do you need to check to see if there are?

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Hi HarleyQuinn,

I need to check because someone may not have chosen any value from the datacombo, in which case the datacombo stays blank (not a NULL option). What I am trying to do is take the value of the datacombo and insert it into a datagrid.

Any help would be appreciated.

Thanks
 
In that case checking the ListIndex property for a value of -1 as suggested by Tracy should work.

Is there any reason that you can't use it in this scenario??

Cheers

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Glad to help [smile]

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
One more thing. Don't use a combo unless you want to allow the user to input data. (If you do, then the data are available in the text property.)

by far the more common use of the combo box is the dropdown list style, which actually isn't a combo box at all.

A little history here: there are two controls, listbox and combobox. Listbox means that the user can't input data, combobox means the user can. Simple means an area on the screen that contains a scrollable list, dropdown means a single list item and a dropdown arrow to show more of the list when clicked.

Listbox predates combobox, and doesn't include a dropdown type. So, rather than change the listbox control to allow simple or dropdown, and have the combobox be a separate control, the dropdown listbox type (with no ability for user input) was rolled into the combobox control and its style property.

I gave you all this because it seemed to me that you're confusing all of this when asking about null values. If you have a list box, as opposed to a combo, there aren't any null values in the list. Why would you, the developer, put null values in the list, as Tracy quite rightly asks? However, the listbox could be in pristine, never had a value selected, state. In this case, the listindex property is -1.

Now, on the other hand, you're also looking at the boundtext property, which suggests that you have bound the control to an outside data source, which itself appears to contain null values. If this is so, perhaps you could change your datasource to exclude null records. If you want to know how to do this, provide more detail about how you're binding your listbox.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top