PC Review


Reply
Thread Tools Rate Thread

Decimnal Places Rounded in Code, but not in the Form

 
 
Philip McC
Guest
Posts: n/a
 
      20th Oct 2008
We have an age calculation that must be rounded and stored.
1) The Form and Table settings are the same I've tried Fixed and General
formats.
2) But everything submitted and processed through the LET statement
is automatically rounded.
We want : 45.4 to be 45.4 and 45.6 to be 45.6
But, the VBA changes it to 45.00 and 46.00.

The form field values do not show this.
-->Is there a VBA or access setting that affects this?<--


 
Reply With Quote
 
 
 
 
dch3
Guest
Posts: n/a
 
      20th Oct 2008
Check the decimal places property on the controls that display the value,
also double check the dataType for the underlying field. Not all Number
dataTypes support fractional values.

"Philip McC" wrote:

> We have an age calculation that must be rounded and stored.
> 1) The Form and Table settings are the same I've tried Fixed and General
> formats.
> 2) But everything submitted and processed through the LET statement
> is automatically rounded.
> We want : 45.4 to be 45.4 and 45.6 to be 45.6
> But, the VBA changes it to 45.00 and 46.00.
>
> The form field values do not show this.
> -->Is there a VBA or access setting that affects this?<--
>
>

 
Reply With Quote
 
Golfinray
Guest
Posts: n/a
 
      20th Oct 2008
You don't have something set to an integer datatype do you? If so it will
just return integers, or whole number. Also, if you int() or val() set
somewhere, it will return integers.

"Philip McC" wrote:

> We have an age calculation that must be rounded and stored.
> 1) The Form and Table settings are the same I've tried Fixed and General
> formats.
> 2) But everything submitted and processed through the LET statement
> is automatically rounded.
> We want : 45.4 to be 45.4 and 45.6 to be 45.6
> But, the VBA changes it to 45.00 and 46.00.
>
> The form field values do not show this.
> -->Is there a VBA or access setting that affects this?<--
>
>

 
Reply With Quote
 
Philip McC
Guest
Posts: n/a
 
      20th Oct 2008
Table Settings
FIELD DATATYPE
DOB Date/Time
AGE Long Integer, Fixed Number (General was tried too)
RoundedAge Long Integer, Fixed Number
TextBox Long Integer, Fixed Number

Form Field Settings
FIELD CONTROL SRC FORMAT
TextBox =DateDiff("y",[DOB],Date(),0)/365 General Number, Auto
RoundedAge =Round([TextBox],2) General Number,
Auto
AGE [AGE]
Fixed, Auto
DOB [DOB]
Date/Time

NOTE: I tried both General Number & Fixed.

FINALLY, [AGE] field is stored in the table via an AfterUpdate for DOB:
Let AGE.Value = Forms![TestForm5]![RoundedAge]

"dch3" wrote:

> Check the decimal places property on the controls that display the value,
> also double check the dataType for the underlying field. Not all Number
> dataTypes support fractional values.
>
> "Philip McC" wrote:
>
> > We have an age calculation that must be rounded and stored.
> > 1) The Form and Table settings are the same I've tried Fixed and General
> > formats.
> > 2) But everything submitted and processed through the LET statement
> > is automatically rounded.
> > We want : 45.4 to be 45.4 and 45.6 to be 45.6
> > But, the VBA changes it to 45.00 and 46.00.
> >
> > The form field values do not show this.
> > -->Is there a VBA or access setting that affects this?<--
> >
> >

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th Oct 2008
Long Integers cannot store decimal points. You'd need Age to be Single or
Double.

However, you should not be storing Age since it changes every day! Simply
calculate the age in a query, and use the query wherever you would otherwise
have used the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Philip McC" <(E-Mail Removed)> wrote in message
news:1E9C9286-5CEA-4CEC-95D1-(E-Mail Removed)...
> Table Settings
> FIELD DATATYPE
> DOB Date/Time
> AGE Long Integer, Fixed Number (General was tried too)
> RoundedAge Long Integer, Fixed Number
> TextBox Long Integer, Fixed Number
>
> Form Field Settings
> FIELD CONTROL SRC FORMAT
> TextBox =DateDiff("y",[DOB],Date(),0)/365 General Number,
> Auto
> RoundedAge =Round([TextBox],2) General Number,
> Auto
> AGE [AGE]
> Fixed, Auto
> DOB [DOB]
> Date/Time
>
> NOTE: I tried both General Number & Fixed.
>
> FINALLY, [AGE] field is stored in the table via an AfterUpdate for DOB:
> Let AGE.Value = Forms![TestForm5]![RoundedAge]
>
> "dch3" wrote:
>
>> Check the decimal places property on the controls that display the value,
>> also double check the dataType for the underlying field. Not all Number
>> dataTypes support fractional values.
>>
>> "Philip McC" wrote:
>>
>> > We have an age calculation that must be rounded and stored.
>> > 1) The Form and Table settings are the same I've tried Fixed and
>> > General
>> > formats.
>> > 2) But everything submitted and processed through the LET statement
>> > is automatically rounded.
>> > We want : 45.4 to be 45.4 and 45.6 to be 45.6
>> > But, the VBA changes it to 45.00 and 46.00.
>> >
>> > The form field values do not show this.
>> > -->Is there a VBA or access setting that affects this?<--
>> >
>> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code outputs currency value rounded to 2 decimal points tamarack007@gmail.com Microsoft Excel Programming 7 2nd Sep 2007 01:01 PM
VB code to place rounded time beside cell of present date AA Arens Microsoft Excel Discussion 3 27th Jun 2007 03:20 PM
data entered in access table displays as a rounded up or rounded d =?Utf-8?B?RGVi?= Microsoft Access 4 12th Sep 2006 10:40 AM
decimal places get rounded Annoyed Microsoft Access 2 20th Aug 2004 08:37 PM
Rounded form corners code? Dean Slindee Microsoft VB .NET 2 1st Aug 2004 10:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:31 PM.