Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunately, the zipped DB I posted here was read only; this generates an error when opening Form EmployeeData but if End is clicked it works OK. Using that DB will save using up space uploading another.

    The field HourlyRate in table EmploymentHistory appears in the form EmpHistory, a sub form of EmployeeData. If EmployeeData is opened, HourlyRate is displayed with two decimal places; the properties of this control are set for 2 places.
    If you tab into the field, the display does not change - hourly rate is still shown with 2 decimal places. However, if the cursor is put into the field by clicking on the field, the display shows the actual arithmetic hourly rate which changes to four decimal places.

    (I know that, in this DB, the table definition for HourlyRate shows the decimal places option is set to Auto but, I have changed this to 2 in the current development DB and the problem still occurs).

    How can I force the field to only ever display two decimal places, please?
    Thanks
    Silverback
    Silverback

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    A currency field stores values with a precision of 4 decimal places. If you want only 2 decimal places, you must round the values.

    You can do this by creating an update query with the following SQL:

    UPDATE EmploymentHistory SET EmploymentHistory.HourlyRate = Round([HourlyRate],2);

    and running it. This will round existing hourly rates.

    To make sure that the hourly rates will remain rounded in the future, change all occurrences of the line

    Me.HourlyRate = Me.Salary / 52 / Me.NumberOfHours / Me.NumberOfWeeks

    to

    Me.HourlyRate = Round(Me.Salary / 52 / Me.NumberOfHours / Me.NumberOfWeeks, 2)

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Hans
    Another nugget of information that I would never have found without the lounge.
    Silverback
    Silverback

Posting Permissions

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