help on VB totals..

Discussion in 'Software' started by in the rain, Nov 29, 2004.

  1. in the rain

    in the rain Private E-2

    help! i've been working on a simple inventory system and i have a problem in getting the total amount of the products bought by a certain customer... i don't know how i would be able to display this total in a textbox... how would i be able to extract and add the totals from the database? do i have to use arrays? i'm really new to VB... please help me!
     
  2. Kodo

    Kodo SNATCHSQUATCH

    build a query.

    Depending on how your database is setup it may go something like this (first english pseudo then real sql )


    Select the total count of records that have the customer id of [customer id you supply]

    SQL="Select Count(ID) from inventorytable where customerid= "& customerid &" "
    set rs=connection.execute(SQL)
    custcount=rs(0)

    execute the query and the value that is returned is your count. Then set the text box value to custcount as displayed in the query above.
     
  3. in the rain

    in the rain Private E-2

    how about the sum of all the total count of records of the same customerID? :D i now have to use SUM right? ;) ...what does custcount=rs(0) mean? :confused: i'm sorry but these codes are really new to me! tnx!
     
  4. Kodo

    Kodo SNATCHSQUATCH

    You are confusing sum and count. If you wan to get a total Record Count of all the items in inventory for a particular customer then you would count the records, not add the records up. That doesn't make sense unless you wanted some dollar value.

    CustCount is a variable I assigned and RS(0) is a the recordset returning the first item in the array . Since all items returned in a recordset are array based and arrays, by default, start with 0 then the first returned record in a single item array is 0.

    is this VBA as in MS-Access or is it vb6.

    If you don't understand these basics concepts then you may want to spend some time in a book reading about variables, arrays and basic SQL. A few hours of reading could help you out alot.

    here's some good resorouces. It's for ASP but the concepts are identical. Only the syntax is different

    www.haneng.com
    www.4guysfromrolla.com
     
  5. in the rain

    in the rain Private E-2

    i used vb6 as frontend and ms-access for my database.. tnx for the resources!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds