Decimal places in forms and tables

O

Ollie*99

I have a form based on a table, with a set of values that are calculated in
VBA (many thanks to the guys yesterday for their input on that), however, i
cannot seem to adjust the number of decimal places for the calculated values.

I have something approaching 10 digits after the decimal place, however, i
only want 2, as they will otherwise not fit into the form's text box, and
aren't needed.

I have changed the field properties on the table and the form to Double,
General Number, 2 decimal places, but this is having no effect. I assume i
have missed something here, can anyone enlighten me?

Ollie
 
B

bcap

It sounds like the calculated values are finishing up as text data rather
than numeric. I think you'll need to post your VBA.
 
M

Maurice

How about putting the round function in your VBA

something like: Round(your calculation here, 2)
This will round the calculation to two decimals.

hth
 
O

Ollie*99

Its pretty basic...

Private Sub Capacity_AfterUpdate()
Annual_Power_Output = [Capacity] * 3.21270138
Cost_per_kWh_DWL = [Total_Cost] / [Annual_Power_Output]
End Sub

When the Capacity value is changed in the table, the Annual Power Output,
and Cost per kWh values are calculated as below. Like i say, the problem is
that it is outputting to about 10 decimal places despite the field properties
on the table and form being 2 decimal places.

Ollie
 
M

Maurice

So: Cost_per_kWh_DWL = Round([Total_Cost] / [Annual_Power_Output],2) should
do the trick.
--
Maurice Ausum


Ollie*99 said:
Its pretty basic...

Private Sub Capacity_AfterUpdate()
Annual_Power_Output = [Capacity] * 3.21270138
Cost_per_kWh_DWL = [Total_Cost] / [Annual_Power_Output]
End Sub

When the Capacity value is changed in the table, the Annual Power Output,
and Cost per kWh values are calculated as below. Like i say, the problem is
that it is outputting to about 10 decimal places despite the field properties
on the table and form being 2 decimal places.

Ollie


bcap said:
It sounds like the calculated values are finishing up as text data rather
than numeric. I think you'll need to post your VBA.
 
O

Ollie*99

It works! Many thanks, please accept this wonderful present as a token of my
appreciation...

|@|@|
~~~~~
##

I have no idea what it is, but enjoy. ;)

Ollie

Maurice said:
So: Cost_per_kWh_DWL = Round([Total_Cost] / [Annual_Power_Output],2) should
do the trick.
--
Maurice Ausum


Ollie*99 said:
Its pretty basic...

Private Sub Capacity_AfterUpdate()
Annual_Power_Output = [Capacity] * 3.21270138
Cost_per_kWh_DWL = [Total_Cost] / [Annual_Power_Output]
End Sub

When the Capacity value is changed in the table, the Annual Power Output,
and Cost per kWh values are calculated as below. Like i say, the problem is
that it is outputting to about 10 decimal places despite the field properties
on the table and form being 2 decimal places.

Ollie


bcap said:
It sounds like the calculated values are finishing up as text data rather
than numeric. I think you'll need to post your VBA.

I have a form based on a table, with a set of values that are calculated in
VBA (many thanks to the guys yesterday for their input on that), however,
i
cannot seem to adjust the number of decimal places for the calculated
values.

I have something approaching 10 digits after the decimal place, however, i
only want 2, as they will otherwise not fit into the form's text box, and
aren't needed.

I have changed the field properties on the table and the form to Double,
General Number, 2 decimal places, but this is having no effect. I assume i
have missed something here, can anyone enlighten me?

Ollie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top