View Full Version : Reading a parameter passed to a report


Gkirkup
04-02-2010, 11:00 AM
I am passing a parameter to a report. How do I get that parameter value into a control on the report? I have tried Me.MyControl = Me.OpenArgs, in both the ON OPEN and ON ACTIVATE event of the report, but the value never gets to the control on the report.
What am I doing wrong?

Robert

vbaInet
04-02-2010, 11:01 AM
How are you passing the parameter? On the Docmd.Openreport method?

Gkirkup
04-02-2010, 11:08 AM
Yes, as the final parameter of DoCmd.Openreport. I tried passing it as a string and a number, in case that made a difference.

Robert

SOS
04-02-2010, 11:13 AM
Have you set a breakpoint to make sure that the OpenArgs is getting set to something? What is your code exactly which sets the openargs?

Gkirkup
04-02-2010, 11:41 AM
Yes, I did test that OpenArgs was getting set. My problem was that it was not getting passed to the control in the report - perhaps the control is not visible at that point? I got around all of this by having a function pass OpenArgs once it got to the report, and in my report control used =MyFunction(). That worked OK.

Robert

SOS
04-02-2010, 11:44 AM
I wish we could have seen it because it does work great. Something you had was causing the problem (I'm 99% sure) and we could have saved the hassle of a function. But since you have it working, no sense going back now.

vbaInet
04-02-2010, 11:51 AM
OpenArgs has not failed me either. Maybe you're missing one comma and not passing it in the OpenArgs argument of the method.

But like SOS said, no point going back. :)