Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    4

    Unanswered: Decimal and DSum

    Does anyone know how to prevent the dsum function from rounding when a decimal is entered. For example, I'll have a field with decimals 2.5 and 1.25. Rather than getting 4.75 I get 5

    The field is set as a decimal, I've also tried setting the field as double.

    Thanks for any assistance.

  2. #2
    Join Date
    Jul 2003
    Location
    Italy
    Posts
    139
    Change decimal position in the text box properties to 2 or whatever you like.
    Marco
    ---Do not send e-mail---
    "New Big Bang Theory: God said unzip universe"

  3. #3
    Join Date
    Aug 2003
    Posts
    4
    Tried doing that, actually it's already set to 2 decimal positions. It seems like the DSum truncates anything that isn't a whole number. Any help is greatly appreciated.

    Originally posted by Marco Del Corno
    Change decimal position in the text box properties to 2 or whatever you like.

  4. #4
    Join Date
    Jul 2003
    Location
    Italy
    Posts
    139
    Are you using it in a query?
    Marco
    ---Do not send e-mail---
    "New Big Bang Theory: God said unzip universe"

  5. #5
    Join Date
    Aug 2003
    Posts
    4
    No ....

    I'm using it in the VB code for a form to get a total of hours spent on a certain project throughout the fiscal year (July 1 - June 30). So depending on which month it is determines which months will be included in the total. Are there any other options with the DSum function besides the standard format DSum(field, table, criteria)?

    Thanks so much for the assistance

    Originally posted by Marco Del Corno
    Are you using it in a query?

  6. #6
    Join Date
    Jul 2003
    Location
    Italy
    Posts
    139
    I had a lot of problems using dsum for hours. I had the same problem and solved not using dsum.

    Try this in your text box:


    txtTotalTime = Int(Sum([Timefield])/60)) & " Hours " & (Sum([TimeField]) mod 60) & " minutes"

    This will take the timefield control and sum hours and minutes.

    The problem gets bigger if you want to calculate working hours. I have an entire book about this subject :-) I found all information in this great forum especially modules to calculate working hours.

    That's all for now... ask if you need those modules or if I missed the subject.
    Marco
    ---Do not send e-mail---
    "New Big Bang Theory: God said unzip universe"

  7. #7
    Join Date
    Jul 2003
    Location
    Italy
    Posts
    139
    oh!

    I found in my 'book' something interesting.

    Microsoft Knowledge Base article - q88657

    Function GetTimeCardTotal: it sums a field of time values in a table and displays the totl in hours and minutes.

    If you can't find it I can post it here!

    It might be your solution!
    Marco
    ---Do not send e-mail---
    "New Big Bang Theory: God said unzip universe"

  8. #8
    Join Date
    Aug 2003
    Posts
    4
    You're great. Thanks I'll go check that out right now.

    I'll get back to you in just a little while.

    Originally posted by Marco Del Corno
    oh!

    I found in my 'book' something interesting.

    Microsoft Knowledge Base article - q88657

    Function GetTimeCardTotal: it sums a field of time values in a table and displays the totl in hours and minutes.

    If you can't find it I can post it here!

    It might be your solution!

Posting Permissions

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