Multiple Data Types in One Textbox

hominamad

Registered User.
Local time
Today, 12:37
Joined
Apr 10, 2007
Messages
20
I have a feeling this maybe can't be done but figured I'd give it a shot anywa. I have a table which has an "amount" column. That column can either hold a percentage value, or a dollar amount. I'd like to be able to approrpriately format the number in my forms depending on the type.

So basically, my question is: Can a single textbox (on a CONTINUOUS form) be conditionally formatted to either percent or currency, based on another column in the recordset?

Thanks!
 
=IIf(Whatever, Format([Amount],"Currency"), Format([Amount],"Percent"))
 
Thanks Paul - where does this go though? In the Format property, or the control source? I couldn't get it to work in either. I'm going to try playing with it in the VB.

Also this is a continuous form. Will it work properly? I want something like:

Amount
--------
45%
67%
$500,00.00
87%
 
I tested it as the control source of a textbox on a continuous form. I assume you replaced "Whatever" with your actual test?
 
First I tried it with something simpler: =IIf(1=1,[amount],55)

I get an error "Circular reference".
 
Actually, the problem was that my textbox was named the same as the control source. I'm almost there now. New problem is that the field isn't editable after formatting.
 
So is editing with conditional formatting not possible?
 
Sure, but you're not using conditional formatting. You can't edit because the control source of the textbox is a formula, not a data field. Conditional formatting lets you change color, bold, etc, but not currency/percent format.

I've never tried to do what you're doing, because storing different types of values in the same field is a normalization problem. I suppose you could have 2 textboxes, one for entry/edit and one for display. The first bound to the data field, the second with the formula.
 

Users who are viewing this thread

Back
Top Bottom