CBO box bound to lookup table, but not all values

dpatfield66

Well-known member
Joined
Apr 6, 2006
Messages
136
Programming Experience
5-10
Ok, I have a lookup table called OBLookup.
This table has a category field, a value field, and some other fields.

I want to bind some comboboxes I have to this table.
But for one combobos, I only want the values from one categor displayed.
And so on...

For example: I have a category of Meds, and about 5 values associated with them. I want my combobox "Meds" to be bound to these 5 values.

I can bind the Meds combobox to the OBLookup Data Table, but not with the criteria Category = "Meds" How do I do this, considering I've got a gazillion more comboboxes,and don't want to clutter up my form with code.

Not that I don't LIKE cluttering up my code, but I just thought there would be a simple way to handle this one.
 
You should set the datasource of your cbo's to a dataview. The dataview class accepts a dataset as argument. You can then specify a rowfilter to filter records. It should look something like the following example:

VB.NET:
public ds as DataSet = FillDataSet()
public dv as new dataview(ds)

dv.rowfilter = "Category = 'Meds'"

cbo1.datasource = dv
...
 
DataViews

Thanks for the advice...the dataviews are working great.
Now, I have one more problem...

When an existing value from a previous record is a bit off from the value in the lookup view, I get a blank value in forms when I open them.

My dropdownstyle is set to dropdown and not dropdown list, but I still get the blank value.

There's got to be some simple way to allow for mispelled or even completely different values that come over from the SQL table. I can "type' in a different value and it stays (due to my dropdownstlye mentioned above), but a value coming over from an existing record gets lost.

I could've sworn at one time that wasn't the case, but now it's happening.
How can I keep my existing values without adding extra textboxes, and stuff like that?
 
Back
Top