Find Record with ComboBox

MrsL

New member
Joined
Dec 19, 2002
Messages
2
Location
Denver, CO
Hi All,
Please bear with me as I am very, very new to VB.Net! What Im trying to do is populate my form based on a selection from a combo box and Im not sure how to do it with .Net. While searching this forum I found a post from shootsnlad dated 8/16/2002 that is the exact same as my problem but I didnt really understand the answer. What Ive done is create a form using the Data Form Wizard. I then created a combo box that is populated with the Primary key from the dataset. I want the user to be able to make a selection from the combo box and display the record on the form. In VBA it would be like Me.Bookmark = Me. RecordsetClone.Bookmark, if that helps. Any help would be appreciated alot!!! Also let me know if Im not being clear.

Thanks in advance!
 
Think I Figured it out..

If anyone is interested, I think I figured it out. Heres the code Im using and it seems to work...if anyone knows a better way Id love to hear it!

Code:
Private Sub cboSearch_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboSearch.SelectedIndexChanged
        If cboSearch.SelectedIndex <> -1 Then
            FindBySSN()
        End If
    End Sub

    Private Sub FindBySSN()
        create a dataview in order to filter rows by ssn...
        Dim dvPersonnel As DataView = New DataView _
            (objdsPersonnel.Tables("tblPersonnel"), "", "SSN", DataViewRowState.CurrentRows)
        get the index of the row which matches the ssn in the combobox...
        Dim rowIndex As Integer = dvPersonnel.Find(Mid(cboSearch.Text, 1, 9))
        display the record that matches the ssn selected in the combobox...
        If rowIndex <> -1 Then
            Me.BindingContext(objdsPersonnel, "tblPersonnel").Position = rowIndex
        End If
        show the current record position...
        Me.objdsPersonnel_PositionChanged()
    End Sub
 
Back
Top