By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,656 Members | 1,893 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,656 IT Pros & Developers. It's quick & easy.

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

Seth Schrock
Expert 2.5K+
P: 2,951
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')

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,712
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
Expert 2.5K+
P: 2,951
That does make sense. Thanks, and it works perfectly.
Dec 1 '11 #3

NeoPa
Expert Mod 15k+
P: 31,712
Excellent :-)
Dec 1 '11 #4

Post your reply

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