Combo boxes database

I am creating a front end for an access database which displays data in text and combo boxes.  When you click a search button on the main form it opens another form which has a combobox on so that you can select to search by name, or box number.  Then when you have entered your data and selected what to search by I would like the application to switch back to the main form and update the text/comboboxes.  

The combo boxes dont scroll through the records.  I tried to sort this with the following, (didnt work).

Dim dt As New DataTable
    Public dv As DataView
    Public dvtwo As DataView
    Dim cm As CurrencyManager
    Dim cmtwo As CurrencyManager
    Dim CurrentRecord As Integer
    Dim Constr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Matt\Desktop\File Tracker.mdb;Persist Security Info=False"

   

    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       




        Dim DA As New OleDbDataAdapter("Select * From Main", Constr)


        Try
            DbMain.Fill(DataSet11, "Main")
            DbLocations.Fill(DataSet11, "Locations")
            DbMatter.Fill(DataSet11, "Matter")
            DbFeeEarner.Fill(DataSet11, "FeeEarner")
            DbOffice.Fill(DataSet11, "Offices")
            DbStatus.Fill(DataSet11, "Status")


        Catch Ex As Exception
            MsgBox(Ex.Message)
        End Try

        DA.Fill(dt)
        dvtwo = dt.DefaultView
        cmtwo = CType(Me.BindingContext(DataSet11), CurrencyManager)
        dv = dt.DefaultView
        cm = CType(Me.BindingContext(dv), CurrencyManager)

        'Bind Textboxes

        TxtClient.DataBindings.Add("Text", dv, "ClientName")
        TxtMatterNumber.DataBindings.Add("Text", dv, "MatterNo")
        TxtCloseDate.DataBindings.Add("Text", dv, "CloseDate")
        TxtNotes.DataBindings.Add("Text", dv, "Notes")
        TxtBox.DataBindings.Add("Text", dv, "BoxNumber")
        TxtDateIn.DataBindings.Add("Text", dv, "DateIn")
        TxtStoreDate.DataBindings.Add("Text", dv, "StoreDate")
        TxtDateRemoved.DataBindings.Add("Text", dv, "RemoveDate")
        TxtDestroyDate.DataBindings.Add("Text", dv, "DestroyDate")


        'Load Originating Location Combo
        CmbLocation.DataSource = DataSet11.Tables("Locations")
        CmbLocation.DisplayMember = "LocationName"
        CmbLocation.ValueMember = "LocationID"
        CmbLocation.DataBindings.Add("selectedvalue", DataSet11, "Main.LocationID")


        'Load FeeEarner ComboBox
        CmbFeeEarner.DataSource = DataSet11.Tables("FeeEarner")
        CmbFeeEarner.DisplayMember = "FeeEarnerName"
        CmbFeeEarner.ValueMember = "FeeEarnerID"
        CmbFeeEarner.DataBindings.Add("selectedvalue", DataSet11, "Main.FeeEarnerID")

        'Load MatterType Combobox
        CmbMatter.DataSource = DataSet11.Tables("Matter")
        CmbMatter.DisplayMember = "MatterTypeName"
        CmbMatter.ValueMember = "MatterTypeID"
        CmbMatter.DataBindings.Add("selectedvalue", DataSet11, "Main.MatterTypeID")

        'Load Status Combobox
        CmbStatus.DataSource = DataSet11.Tables("Status")
        CmbStatus.DisplayMember = "StorageName"
        CmbStatus.ValueMember = "StatusID"
        CmbStatus.DataBindings.Add("selectedvalue", DataSet11, "Main.StatusID")

        'Load Office Combobox
        CmbOffice.DataSource = DataSet11.Tables("Offices")
        CmbOffice.DisplayMember = "OfficeName"
        CmbOffice.ValueMember = "OfficeID"
        CmbOffice.DataBindings.Add("selectedvalue", DataSet11, "Main.OfficeID")

    End Sub

Private Sub NavigationButtons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFirst.Click, BtnLast.Click, BtnNext.Click, BtnPrevious.Click, BtnMainSearch.Click
        Select Case sender.Name
            Case "BtnFirst"

                cm.Position = 0

                cmtwo.Position = 0

            Case "BtnPrevious"

                cm.Position -= 1
                cmtwo.Position -= 1

            Case "BtnNext"

                cm.Position += 1
                cmtwo.Position += 1

            Case "BtnLast"

                cm.Position = dv.Count - 1
                cmtwo.Position = dv.Count - 1

            Case "BtnMainSearch"
                Dim fs As New Search
                fs.Owner = Me
                fs.ShowDialog()

        End Select

    End Sub
matt_swinburneAsked:
Who is Participating?
 
Bob LearnedCommented:
I am confused.  Why do you have two CurrencyManagers?   Why do you bind some controls to the DataView, and others to the DataSet?

Bob
0
 
Bob LearnedCommented:
What are the combo boxes doing?  Displaying nothing?  Displaying incorrect text?

Bob
0
 
TorrwinCommented:
What exactly do you mean the combo boxes don't sort through the records?  Do you mean they aren't getting any data from the database?
0
 
matt_swinburneAuthor Commented:
The combo boxes use an IDno in the table main to look up the, for example, locations name kept in the table locations.  The code picks up this but wont cycle through the records.  (Basically the coding for the navigation buttons doesnt work, i think!)

Thanks for the help

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.