View Full Version : calculated controls


arage
01-12-2001, 07:17 AM
Hi,
I’ve learned enuff about calculated controls to know how to make them & having to ask this question is making me feel ridiculous but I’ve done all I can & cannot seem to resolve the problem.

My form based on a query has 2 fields, region code & event #. I concatenate these 2 values in a 3rd calculated control called ref#. if either of the former fields is blank, then ref# is null, here’s my code.

=IIf(IsNull([Event form.RegionCode]) And IsNull([Event form.Event#]),Null,[Event form.RegionCode] & "-" & [Event form.Event#])

But the above now gives #name? error although the fields appear exactly on the form as mentioned above.

Binding ref# to a singular field works, but the minute I start trying to join 2 fields together it starts falling apart.

Any ideas?
Thanks!

R. Hicks
01-12-2001, 10:02 AM
I'm guessing that what you want to do is that if either of the controls are empty then show nothing in the ref# control. If this is true then you need to use "Or" instead of "And" in the code. Using "And" will give you half of the expression if either is null. Also if the controls are in the current form you can reference by the method below:

If the controls you mention are in the current form, try the following as the Control Source of the control you have named ref#.

=IIf(IsNull([RegionCode]) Or IsNull([Event#]),Null,[RegionCode] & "-" & [Event#])

HTH
RDH

[This message has been edited by R. Hicks (edited 01-12-2001).]