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

Remove blank items from combobox

Status
Not open for further replies.

johnisotank

Technical User
Aug 8, 2008
258
GB
Hi all,

could someone point me in the direction of a solution for this pls..

I have a combobox which is populated from my tblBookingInUsers which looks like this

RowID, Depot1, Depot2, Depot3
1, John, Brian, Dave
2, Ian, Nigel, Mike
3, NULL, Alan, Richard

I then use some code to populate the textbox, I would like to use the items from the 'Depot1' column..
Code:
'Set the binding source to look at
Me.MyComboBox.DataSource = tblBookingInUsersBindSource
'Set the column to look at
Me.MyComboBox.DisplayMember = "Depot1"

Looking at depot1, the combobox is populated with John, Ian and a Null (Which shows as blank) value.

Can someone tell me how to remove this blank value?
note: sometimes there may be more than 1 NULL value.

Any help at all is greatly appreciated.

thanks
John
 
You don't give what you expect the NULL to be.....do you just not want to show that record in the combobox??? If so, the try:
Code:
'Set the binding source to look at
Me.MyComboBox.DataSource = tblBookingInUsersBindSource
'Filter the NULLs out
tblBookingInUsersBindSource.Filter = "Depot1 IS NOL NULL"
'Set the column to look at
Me.MyComboBox.DisplayMember = "Depot1"
You may to work with the Filter to include other values, such as blank or empty string. But basically, the Filter property acts a SQL Where clause...

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Robert, thats correct I just don't want NULLS to show in the combobox and with your code it's working perfect now.

I think this .filter option may benefit other parts of my app as well so thank you very much for that.

And I do need to include empty strings so thanks for that as well.

Cheers

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top