Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine text in number field?

Status
Not open for further replies.

Allilue

Technical User
Sep 14, 2000
189
GB
hello,

i have a field which is set to be a number. but this is a calculated field. the calculated field is x/y, where y can equal to zero. i tried to set it so that if y=0, then "N/A", but that seems to throw off all of the other numbers. can i do this? right now, i have set it so that if y=0, 0. but this is not what i'm looking for. is there a way to avoid this problem???

thanks...
 
Alilue,

You are on the 'right track'. You can only store the designated type in a field. You can Store NOTHING (or null) in any field, so your expression should be:

If (Y) then
[tab] x/y
End If

From a braoder perspective, you probably shouldn't be storing a calculated value at all. In the general sense, batabase concepts currently favor storing the minimal ammouit of information, and doing 'calculations' to derive items which may be derived. Within a form or report, you may easily do what you are attempting to do in the table/filed, because the 'controls' do not generally "respect" data typing, and will cheerefully place the "N/A" in the value field.




MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
I'm not sure I get what you mean. The calculation (x/y) is currently being done in a query. The form which it is being shown in is based on that query. Are you saying that if I have the "N/A" in the query, I won't be able to because it is set to a numeric value? I also tried to ignore that calculation in the query and do the calculation straight on the form. I also got an error and will not allow that either. I hope I'm making sense....
 
Hmmmmmmmmmmmmm,

Let's see if I can Answer the points one at a time (hopefully in the order posted?).

I thought/assumed the calc was being placed into a table. Mea culpa, although the same 'rule' applies. (first question?)

If you designate the field as numeric, you cannot place text in it. Ergo no "N/A". However if you change the field type to general it should be O.K. (Second Question?)

I don't quite know what " ... ignore that calculation in the query ... ". It is generally difficult to ignore errors in queries. Did you remove it?

You should be able to place the equivalent calculation in the control's "control source", but it needs to be in the asn "=IIF(....)" format.

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top