Tuesday, March 20, 2012

Referencing field by name in code

I have a field (Fields!myfield) that I would like to pass in the name as two parts(Code.GetField("my","field") and dynamically return either a reference to myfield or the value itself.

I'm getting Reference to a shared field requires a shared reference error when I try to return Fields!Myfield.Value from the function.

I would like the ability to pass in the name of a field to a function and return the actual field name (or value of the field) to the report. Any ideas?

That was easy. Fields("my" & code.getname("test")).Value seems to work well.

No comments:

Post a Comment