
How to write code for if field exists
Hi,
In addition to the column Heading property that will insure you that the
field is already included, as suggested by Terry, in a general case, you can
check if the fields name return an error or not:
On Error Resume Next
Dummy=rst.Fields("TheName").Name
FieldExist = ( Err.Number <> 0 )
Hope it may help,
Vanderghast, Access MVP
Quote:
>I have a report based on a query which in turn is based on a cross tab.
The
>cross tab Column headings returns fields 1 through 20 only (never more,
never
>less). But sometimes there is a blank and that heading does not appear.
So
>when I have a text box in the report for heading 17 and 17 is presently
null, I
>get an error. This makes sense because 17 is not a field.
>What can I write in the ControlSource for each text box to say if field
does
>not exist print null?
>If I must use code, how would the code look?
>Doyle60