473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Why won't CCur() make the value be currency?

Seth Schrock
2,965 Expert 2GB
I have an unbound textbox that I want to have part of it be a dollar amount, but it isn't working. Here is the code in textbox:
Expand|Select|Wrap|Line Numbers
  1. ="* " & [NumToGetSpecialRate] & 
  2. Switch([NumToGetSpecialRate]=1,"st",[NumToGetSpecialRate]=2,"nd",[NumToGetSpecialRate]=3,"rd",[NumToGetSpecialRate]>=4,"th") & 
  3. " file of same month " & 
  4. CCur([SpecialRate])
The last line, CCur([SpecialRate]) should give a dollar amount, but it isn't. I get just a number with no decimal. It does return the correct number, just not as a dollar amount. For example, one record returns this value * 3rd file of same month 12, but I want to be * 3rd file of same month $12.00.


Does CCur() work with variables but not with fields? Is there a better way to do this?
Dec 1 '11 #1

✓ answered by NeoPa

CCur() is working perfectly as expected. It converts the argument to a Currency value. Of course, as soon as you add that Currency value to the end of the string it is automatically re-converted to string in the standard way, which does not include determining a format string from the type of the value it used to be. Does that make sense?

What you need to do here is to use the Format() function to prepare the string representation of your value :
Expand|Select|Wrap|Line Numbers
  1. ='* ' & [NumToGetSpecialRate] &
  2. Switch([NumToGetSpecialRate]=1,'st',[NumToGetSpecialRate]=2,'nd',[NumToGetSpecialRate]=3,'rd',[NumToGetSpecialRate]>=4,'th') & 
  3. ' file of same month ' & 
  4. Format([SpecialRate],'Currency')

3 5321
NeoPa
32,556 Expert Mod 16PB
CCur() is working perfectly as expected. It converts the argument to a Currency value. Of course, as soon as you add that Currency value to the end of the string it is automatically re-converted to string in the standard way, which does not include determining a format string from the type of the value it used to be. Does that make sense?

What you need to do here is to use the Format() function to prepare the string representation of your value :
Expand|Select|Wrap|Line Numbers
  1. ='* ' & [NumToGetSpecialRate] &
  2. Switch([NumToGetSpecialRate]=1,'st',[NumToGetSpecialRate]=2,'nd',[NumToGetSpecialRate]=3,'rd',[NumToGetSpecialRate]>=4,'th') & 
  3. ' file of same month ' & 
  4. Format([SpecialRate],'Currency')
Dec 1 '11 #2
Seth Schrock
2,965 Expert 2GB
That does make sense. Thanks, and it works perfectly.
Dec 1 '11 #3
NeoPa
32,556 Expert Mod 16PB
Excellent :-)
Dec 1 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bill Stanard | last post by:
I have had no success using the format function as follows (the two lines of code run one after the other): 'displays a running total of lblAmtdue.Caption 'contents in txtTotal.Text...
1
by: DaveA | last post by:
I am attempting to have an entry on a form that will format the entry to a currency amount. For example, if the user types 3452, I would like the form to store/display 34.52. If the user...
0
by: Tim Roberts | last post by:
It looks to me like the handling of the currency type in an ADODB connecction from Python is broken. Currency data in an Access database is stored as a 64-bit integer, scaled by 10000. In an...
2
by: Julia Soare | last post by:
Hello all, I am trying to display a currency field from an access db on an ASP page. The only problem i found is that if there is a 0 (zero) after the decimal i.e. 79.60 it is not displayed. ...
5
by: Mukesh Kumar | last post by:
hi I am trying to pass range parameters to crystal reports from my .net environment. The start and end values of the range parameters are of currency type. I need to convert the number to currency...
3
by: Dalan | last post by:
Is there any code available to address currency rounding problems in Access 97? Apparently, selecting currency type table fields does not resolve the problem. For instance, in my form I have a...
1
by: J.J. | last post by:
Hi, i have in my table/form two fields, first is number_field(decimal) and second is combo with two values from other table(USD and EURO). now i want that after i select USD the number_field is...
2
by: Chris | last post by:
Hi all, I'm wanting to divide a currency total in half but can't think of a way of doing it. The idea is to split a profit text box in two therefore showing 2 amounts which add up to the total...
5
by: Steven Smith | last post by:
Hi, I'm trying to write a simple program to print invoices for people I do work for. I've got a form with textboxes for descriptions and amounts for items, and some code for printing the...
2
by: dbfrey | last post by:
This is the oddest thing I've ever seen. We have an aspx page with some user controls, one is a main, another is a status, which has an edit button. on the main control, we have some dropdowns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.