Link to home
Start Free TrialLog in
Avatar of sherrick123
sherrick123

asked on

Filter a combobox using a dataset

I have a combobox that is filled in by a data set.  I want to now filter all the entries that start with a 4
I tried using select and it would not work.

Here is my code

        Dim rf As dsFileNetTypes.KDOT_DOC_SUBTYPERow  'filenet attribute

        daFileNetTypes.Fill(DsFileNetTypes1) 'Filling the data adapter with the dataset for filenet subtype attributes

        'filling in the combobox for the filenet attributes
        For Each rf In DsFileNetTypes1.KDOT_DOC_SUBTYPE
            cboFileNetDoc.Items.Add(rf.DOC_SUBTYPE)
        Next

How do i write the select item.

Thanks


Avatar of CreateObject
CreateObject

Filter the data using whatever SQL query you're using to populate the box in the first place; if you supply your SQL query, I can help with that.
Avatar of sherrick123

ASKER

SELECT DOC_SUBTYPE FROM dbo.KDOT_DOC_SUBTYPE

Do i modifiy it on my data adapter then??
Change the query to:

"SELECT DOC_SUBTYPE FROM dbo.KDOT_DOC_SUBTYPE WHERE SUBSTRING(DOC_SUBTYPE,1,1)='4'"

But now the question is: will the filter always be '4', or will it change based on user input?  If so, is that input coming from a textbox, combo box, etc.?
I keep on getting an error on this part of my code

 daFileNetTypes.Fill(DsFileNetTypes1) 'Filling the data adapter with the dataset for filenet subtype attributes
1) Were you getting that error before?
2) What error, exactly, are you getting?
3) Can you supply more code so I can see the SQL query in context?
Okay fixed my error.  I did find out though I need entries with 44  but now when I put the following code in I get nothing??
WHERE SUBSTRING(DOC_SUBTYPE,1,1)='44'
Doh... its the length of the substring....

One other note.
Is there a way to actually do the select on the when I fill the combobox

    'filling in the combobox for the filenet attributes
        For Each rf In DsFileNetTypes1.KDOT_DOC_SUBTYPE
            cboFileNetDoc.Items.Add(rf.DOC_SUBTYPE)
        Next
That way I can change the filters if the user would like to
ASKER CERTIFIED SOLUTION
Avatar of CreateObject
CreateObject

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Learned
Did you try something like this?

   Dim table As dsFileNetTypes.KDOT_DOC_SUBTYPE = DsFileNetTypes1.Tables("KDOT_DOC_SUBTYPE")
   Dim rows As dsFileNetTypes.KDOT_DOC_SUBTYPERow() = table.Select(String.Format("Like '{0}%' ", 4))

Bob
I will give it a try Thanks Again...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial