Results 1 to 2 of 2

Thread: Select Sum question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    92

    Select Sum question

    How do I get the Sum into a label? The Access table does not have an order total. I need the program to calculate this after every item is added.
    Here is what I have tried.

    VB Code:
    1. Public Sub ordertotal()
    2. Dim OTotal As String
    3.  Dim SQL As String
    4.  SQL = "Select Sum(LineTotal) As OTotal From Orders Where OrderNumber LIKE '" & txtOrderNumber.Text & "'"
    5.  
    6.  
    7.    rsOrder.Open SQL, cnOrder
    8.    
    9.    lblTotal.Caption = rsOrder.Fields(OTotal)
    10.    rsOrder.Close
    11. End Sub

  2. #2
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,302

    Re: Select Sum question

    Use quotes.

    VB Code:
    1. lblTotal.Caption = rsOrder.Fields("OTotal")
    The secret of creativity is knowing how to hide your sources...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width