Set Control Source Only if Field Name Exists (1 Viewer)

gschimek

Registered User.
Local time
Today, 08:56
Joined
Oct 2, 2006
Messages
102
I think this might be fairly simple, but I'm at a loss as to how to do it. In a report, I want to set a text box's record source to the value of a field name in another table like this:

CurrentData.ControlSource = DLookup("[CurrentTEC]", "[tblCurrentTEC]")

There are times when the value of "CurrentTEC" does not correspond to a field name in the query that the report is based on, so I get a runtime error 3070.

I just need to know how to put some error checking into the VB to set the control source ONLY IF the field name exists in the current query that the report is based on.

Thanks.
 

HiTechCoach

Well-known member
Local time
Today, 08:56
Joined
Mar 6, 2006
Messages
4,357
If it were me doing this, I would just make sure the field always exists in the record source.

Here is am example of a cross tab query that dynamically fills the columns

Dynamic report
 

Users who are viewing this thread

Top Bottom