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

Adding VB routine breaks report calculated field with #NAME?

Status
Not open for further replies.

rossmcm

Programmer
Jun 28, 2000
16
0
0
I want to be able to write a numeric value in a report, but not write anything if the value was zero. So I was going to make the control source for the text box:

=ShowNumberIfNonZero ([Quantity])

and ShowNumberIfNonZero was to be a VB function that returned the number if non-zero, or a null string otherwise. All was going fine until I actually added the the function.

I have other text boxes on the report that are calculated fields, i.e. the Control source property is not just "FirstName", but rather

=[FirstName] + " " + [LastName]

It seems that adding a VBasic routine breaks the ability to specify the expression as the control source, i.e.

=[FirstName] + " " + [LastName]

causes an error (the text box displays #NAME?). If the VB routine is not there, this calulcated field works fine.

Even if I have a VB function that's not called anywhere, as long as it's present, I can't specify expressions as the control source of the report text boxes.

I'm really keen to know why this is.
 
Even this ?
=[FirstName] & " " & [LastName]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yep, even

=[FirstName]

by itself. The interesting thing is, if I close the DB, and open it again, the fields display OK in the report, but if I switch the design mode, open the code window, then switch back to Preview, all of the calculated control sources go to #NAME?

I know the answer will be a simple one....

I've got a sample DB that demonstrates it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top