?
Solved

Combo boxes database

Posted on 2005-05-09
4
Medium Priority
?
228 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:matt_swinburne
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13961898
What are the combo boxes doing?  Displaying nothing?  Displaying incorrect text?

Bob
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 13962551
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
 

Author Comment

by:matt_swinburne
ID: 13962986
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
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 13967116
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question