ComboBox has to be selected TWICE to generate data results on bound fields of labels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nectar
    New Member
    • Mar 2013
    • 2

    ComboBox has to be selected TWICE to generate data results on bound fields of labels

    Hello,
    I have a two tables in my database (Customer, Transaction) which are related using the CustomerID. I have dragged and dropped the fields of Customer on my form using Visual Studio tools. When I select a different customer using the combo menu cboCustomer the fields of the Customer such as (name, last name, telephone) get updated. However, the fields related to the particular customer on the Transaction fields i.e. TransactionID, description etc are not.
    Now, if I select the same customer TWICE, then the fields of Transaction are displayed.

    What I'm I doing wrong?

    Thanks!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It would help to see the code.

    Comment

    • nectar
      New Member
      • Mar 2013
      • 2

      #3
      Hi Rabbit. I have dragged and dropped the controls from the data sources. This is what I have in the form load event and selected index change methodd of the cboCustomerName :


      Code:
          Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
              'TODO: This line of code loads data into the 'DbPBDataSet.Customer' table. You can move, or remove it, as needed.
              Me.CustomerTableAdapter.Fill(Me.DbPBDataSet.Customer)
              'TODO: This line of code loads data into the 'DbPBDataSet.Employee' table. You can move, or remove it, as needed.
              Me.EmployeeTableAdapter.Fill(Me.DbPBDataSet.Employee)
      
      
              grpDealerSessions.Enabled = False
              grpTables.Enabled = False
              lblSessionIDRes.Text = "No Running Session"
              'TODO: This line of code loads data into the 'DbPBDataSet.Session' table. You can move, or remove it, as needed.
              Me.SessionTableAdapter.Fill(Me.DbPBDataSet.Session)
            
      
              'TODO: This line of code loads data into the 'DbPBDataSet.DealerSessions' table. You can move, or remove it, as needed.
              Me.DealerSessionsTableAdapter.Fill(Me.DbPBDataSet.DealerSessions)
      
      
              'TODO: This line of code loads data into the 'DbPBDataSet.Game' table. You can move, or remove it, as needed.
              Me.GameTableAdapter.Fill(Me.DbPBDataSet.Game)
              
              lblDateTime.Text = Now.ToString
              'TODO: This line of code loads data into the 'DbPBDataSet.Transaction' table. You can move, or remove it, as needed.
              ' Me.TransactionTableAdapter.Fill(Me.DbPBDataSet.Transaction)
             
      
          End Sub
      
      ----------------
      
      Private Sub cboCustomerName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCustomerName.SelectedIndexChanged
              Try
      
                  Dim iCountBuyins, iSumBuyins, iSumCashouts, iBiggestWin, iBiggestLoss As Integer
      
                  Thread.CurrentThread.CurrentCulture = New CultureInfo("el-GR", False)
                  Me.TransactionTableAdapter.FillByCustID(Me.DbPBDataSet.Transaction, CType(lblCustomerID.Text, Integer))
      
                  iSumBuyins = CType(TransactionTableAdapter.scalarTotalBuyin(lblCustomerID.Text), Integer)
                  lblSumBuyins.Text = iSumBuyins
      
      
                  iCountBuyins = CType(TransactionTableAdapter.scalarCountbuyins(lblCustomerID.Text), Integer)
                  lblSumBuyins.Text = iCountBuyins
      
                  iSumCashouts = CType(TransactionTableAdapter.scalarCashouts(lblCustomerID.Text), Integer)
      
                  iBiggestWin = CType(TransactionTableAdapter.scalarBiggestwin(lblCustomerID.Text), Integer)
                  iBiggestLoss = CType(TransactionTableAdapter.scalarBiggestloss(lblCustomerID.Text), Integer)
      
                  lblBiggestWinRes.Text = iBiggestWin.ToString("c")
                  lblBiggestLossRes.Text = iBiggestLoss.ToString("c")
      
      
                  ' Displays i formatted as currency for the CurrentCulture.
                  ' This will override any user settings and display the euro symbol.
      
                  lblTotalRes.Text = (iSumCashouts - iSumBuyins).ToString("c")
                  ' FormatCurrency(iCashouts, , , TriState.True, )
                  Me.TransactionBindingSource.Position = Me.cboCustomerName.SelectedIndex
              Catch ex As System.Exception
                  System.Windows.Forms.MessageBox.Show(ex.Message)
              End Try
          End Sub
      Last edited by Rabbit; Mar 8 '13, 03:08 AM. Reason: Please use code tags when posting code.

      Comment

      Working...