Runtime error 2465 mystry

B

Bill

What might cause a Runtime error 2465 (can't find
field referred to in your expression)?

The offending statement (below) in the Detail event
raises the error. Both Orchestra and CondName are
fields defined in the report's underlying query and they
both show up in the VBA object browser for the
report in question.

In verifying the above, I created a bound text box
and selected Orchestra as its control-source....no problem.

Me.tbOchCond = Me.Orchestra & vbNewLine & Me.CondName & " Conducting"

where tbOchCond is an unbound text box.

Bill
 
B

Bill

Interesting, I bound the text box to:
=[Orchestra] & Chr(13) & Chr(10) & [CondName] & " Conducting"
and the reference problem did not occur.

I'm still in need of the knowledge as to why the un-bound text
box can't be set as per my original post.

Thanks,
Bill
 
D

Duane Hookom

With reports, it isn't enough to only have the fields in the record source.
You must bind the fields to controls if you want to reference them in code.
 
B

Bill

Thanks Duane. If I can't deal with such cases as was shown
in my 2nd post, I'll simply obtain them from "invisible" bound
controls. Is there a better way?
Bill
 
D

Duane Hookom

I'm not aware of a better method if you need to use code to refer to the
value of a field. There is no reason to use code if you can simply place an
expression in a controlsource.
 
B

Bill

Oh for sure, I'd only mess with invisible controls if the
situation demanded otherwise. Though I didn't try it, I
assume I could even use a function invocation in the
controlsource if I needed to run some code.
Thanks again,
Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top