Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   Sum as type... (https://www.askmehelpdesk.com/showthread.php?t=37195)

  • Oct 15, 2006, 02:52 AM
    sukkarfarid
    Sum as type...
    http://www.moq3.com/pics/up/g_11_10_06/7190c4c32e.jpg

    http://www.moq3.com/pics/up/g_11_10_06/ad7956cd79.jpg

    http://www.moq3.com/pics/up/g_11_10_06/f3a4e126de.jpg

    http://www.moq3.com/pics/up/g_11_10_06/fcbe752fc5.jpg

    Thanks a lot
    Farid Sukkar
  • Oct 15, 2006, 04:30 AM
    ScottGem
    It would help if you told us what platform you are working in. The code appears to be Access VBA. So I'll answer for that.

    First you don't actually need any code to do this. If you set the ControlSource of the No3 Control to:

    =IIF([Type] = "Output",([No1]*-1)*[No2],[No1]*[No2])

    That will do what you want.

    Second, As a general rule we do NOT store calculated values. Therefore to sum the results, you need to use a query. In Query Design mode add your table and add the three fields (Type, No1, No2). Then add a 4th column with the expression:

    No3: IIF([Type] = "Output",([No1]*-1)*[No2],[No1]*[No2])

    Now on your form, add unbound controls with a ControlSource of:

    =DSUM("[No3]","Queryname","[Type] = 'Output'")
    =DSUM("[No3]","Queryname","[Type] = 'Input'")
  • Oct 17, 2006, 12:52 AM
    sukkarfarid
    1 Attachment(s)
    thank you ScottGem for help me...
    I try the code you give to me... and I have a problem... that the sum of result of all
    input , and of all output..

    I upload to you the program picture , and I upload to you my test program...
    http://www.moq3.com/pics/up/g_15_10_06/ec36096e9e.jpg

    please help me.. thank you very much to you .
    Best Regards
    Farid Sukkar
  • Oct 17, 2006, 07:09 AM
    ScottGem
    I told you what to do, using the DSUMs. Did you try that?
  • Oct 31, 2006, 02:04 AM
    sukkarfarid
    thank you for help me...
    I try the query , and it's a successfully query...
    I have question for this query...
    when I input the data on the table the sum of this data not show , but when I go to next record and back to my record , the sum of data appears .

    how I can when I input the data the... the sum appear direct

    Thnaks
    Farid
  • Oct 31, 2006, 06:26 AM
    ScottGem
    Again, as a general rule we don't store calculated values. Use the DSum to display the value wherever needed.

  • All times are GMT -7. The time now is 06:47 AM.