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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contatenate and null

Status
Not open for further replies.

FrankMars

Technical User
Dec 20, 2010
67
US
I'm a beginner with Access. I have contatenated an equal sign (=) to a field in a query expression, getting a desired result such as "= $50.33". How would I prevent the = sign from showing in null fields?
Thank You in advance.
 
string & null = string
string + null = null

so you can do something like
"=" + [fieldName]
instead of
"=" & [fieldName]
 
Thanks MajP, unfortunately its not working for me. My expression is RateCalc: " = " & [Price]/[SF]. When I replace the & with + I see the null fields blanking out but get a #Error in the other fields in the column.
 
Sorry that only works with strings and your value is a currency. This would work
ratecalc: IIf(IsNull([Price]),Null,"= " & [Price])
 
What about this ?
Code:
RateCalc: IIf(Price Is Null OR Nz(SF,0)=0,""," = " & Price/SF)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
MajP- The code worked fine on the price portion of the formula, the fields with content have the = sign and the fields w/o content have no = sign. But when I divide by the SF field I get the #Error.

PHV- The code worked fine. The result numbers have 13 digits after the decimal. How would I format them with a $ sign and 2 digits after decimal?
 
If this is in a query, in design view you can right click on the field and select properties. You can select currency from the Format pulldown.
 
oops, strike two. I forgot about the "=" sign so you will have to use a format function.
 
Try
RateCalc: IIf([Price] Is Null Or Nz([SF],0)=0,"",Format([Price]/[SF],"= $#.##"))
 
Thanks MajP, that works good. We've got =,$,digits,and blank null fields. The last challenge for this column is the zero values, which are now reading "= $." Would there be a way for them to be blank?
 
Try
IIf(Nz([Price],0)=0 Or Nz([SF],0)=0,"",Format([Price]/[SF],"= $#.##"))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top