Results 1 to 4 of 4

Thread: Multiplying Field Values

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Unhappy

    Given a simple Access DB Table with the following:

    Item UnitPrice Qty

    Muffler $28.00 3
    Horn $10.00 2

    Is it possible for or in VB to create a fourth field "Totals" that multiplys the values of UnitPrice times Qty and places the results there, i.e.,

    Item UnitPrice Qty Totals

    Muffler $28.00 3 $84.00
    Horn $10.00 2 $20.00

  2. #2
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274
    I can't figure out exactly what you want. Could you be more explicit? do you have any code segment that want to be better?
    Ulises Vázquez
    [size=1.7]Oracle DBA Certified Professioanl
    Visual Basic 6 Developer
    Crystal Reports Designer
    [/size]

  3. #3
    Member
    Join Date
    Jun 2000
    Location
    Perth Western Australia
    Posts
    41
    You can do this in one of two ways. Firstly you could create a query at the database level that created the new field based on the calculation, or alternatively through VB you could open a recordset with the same SQL and as with the previous way it creates a dynamic field for your use.

    The SQL for the query would be

    SELECT tblParts.Item, tblParts.Quantity, tblParts.Cost, [quantity]*[cost] AS Total
    FROM tblParts

    You can see here that we create a field by the code[quantity]*[cost] AS Total

    So when you open the recordset you will have access to all four fields (Item,Quantity,Cost,Total) just like a table.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Talking

    Thanks CGTS, this is what I was looking for

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