PC Review


Reply
Thread Tools Rate Thread

changing number formats in VBA

 
 
John Milward
Guest
Posts: n/a
 
      17th Mar 2006
Hi

I have created a report which prints tables of numbers.
I need to change the number of decimal places shown for each table
I have an additional field (txtRes) that specifies the number of decimal
places

I have tried the following code in Detail_Format & Detail_Print

Select Case txtRes
Case 0.1
Me.txtResult.DecimalPlaces = 1
Case 0.01
Me.txtResult.DecimalPlaces = 2
Case Else
Me.txtResult.DecimalPlaces = 0
End Select

The case statement is responding to txtres, but the statement
Me.txtResult.DecimalPlaces = ? does nothing

The design properties for txtResult are set to fixed Format and Decimal
places = 0

Any help would be appreciated

TIA

John


 
Reply With Quote
 
 
 
 
Wayne Morgan
Guest
Posts: n/a
 
      17th Mar 2006
The DecimalPlaces property to limit the maximum number of decimals
displayed, it won't give you trailing zeros. If that is what you need, then
you'll need to adjust the Format property of the textbox also.

Select Case txtRes
Case 0.1
Me.txtResult.DecimalPlaces = 1
Me.txtResult.Format = "0.0"
Case 0.01
Me.txtResult.DecimalPlaces = 2
Me.txtResult.Format = "0.00"
Case Else
Me.txtResult.DecimalPlaces = 0
End Select

If you want commas in for separators also, you'll need to expand the format.

Me.txtREsult.Format = "#,##0.00"

--
Wayne Morgan
MS Access MVP


"John Milward" <(E-Mail Removed)> wrote in message
news:dveceu$t0s$(E-Mail Removed)...
> Hi
>
> I have created a report which prints tables of numbers.
> I need to change the number of decimal places shown for each table
> I have an additional field (txtRes) that specifies the number of decimal
> places
>
> I have tried the following code in Detail_Format & Detail_Print
>
> Select Case txtRes
> Case 0.1
> Me.txtResult.DecimalPlaces = 1
> Case 0.01
> Me.txtResult.DecimalPlaces = 2
> Case Else
> Me.txtResult.DecimalPlaces = 0
> End Select
>
> The case statement is responding to txtres, but the statement
> Me.txtResult.DecimalPlaces = ? does nothing
>
> The design properties for txtResult are set to fixed Format and Decimal
> places = 0
>
> Any help would be appreciated
>
> TIA
>
> John
>
>



 
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
How do I get different margin formats without changing page number Roxysrfr29 Microsoft Word Document Management 1 18th Jul 2008 08:24 PM
Changing Number Formats based upon value DaveyC Microsoft Excel Misc 3 14th May 2008 08:20 PM
Changing Phone Number Formats Tha BeatMaker Microsoft Excel Programming 8 15th Jul 2005 12:14 AM
Changing Number Formats =?Utf-8?B?U00=?= Microsoft Access 1 15th Feb 2005 04:39 PM
Help - number formats changing MSL Microsoft Excel Misc 1 6th Dec 2003 12:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:02 AM.