how to access a text box on a report (1 Viewer)

Blackelise

aka Andrew
Local time
Today, 02:50
Joined
Jun 13, 2012
Messages
35
Hi,

I am seeking to write a value to a field on the report that has been passed from a form using OpenArgs. The value is received by the report but I cannot get the report to display it.

Details:
I have a text box in report design, it is called ReportType. ReportType does not exist on the supporting query, so access2007 is telling me:

- Invalid Control Property: Control Source
- No Such Field in the Field List

The code that I have on report load is:
Code:
Private Sub Report_Load()
         Me.ReportType = Me.OpenArgs
End Sub

When I run the sequence (clicking a button) I am asked to enter a parameter value for ReportType prior to the report loading (It is this entered value that gets printed, this is just adding more confusion into the mix....).

I then get a runtime error ‘You can't assign a value to this object', debug highlights the code above but also shows that Me.ReportType is set to the value in Me.OpenArgs.

Once again your wisdom is sought.

Thanks.
 

G37Sam

Registered User.
Local time
Today, 05:50
Joined
Apr 23, 2008
Messages
454
You can change the control source of that textbox to something like =[forms]![myform]![MyPassedValue]

I'm assuming that value is copied straight from a form? Or did I misunderstand?
 

Blackelise

aka Andrew
Local time
Today, 02:50
Joined
Jun 13, 2012
Messages
35
Thanks. But what I had omitted was that the value for ReportTitle will be based on a flag which will change as the Form (an order entry form) changes its status as progresses. So depending on the status when the user clicks the print button the value passed via OpenArgs will have its value set - eg Quote, Order, Invoice.

It must be possible to access an unbound field on a report via coding....I just don't know how...
 

bob fitz

AWF VIP
Local time
Today, 02:50
Joined
May 23, 2011
Messages
4,731
Try:
Me.ReportType = Me.OpenArgs
in the On Print or On Format event of the section (Header,Detail or Footer) that holds the textbox.
 

Blackelise

aka Andrew
Local time
Today, 02:50
Joined
Jun 13, 2012
Messages
35
Thanks.

I have tried as suggested but I still get a runtime error ‘You can't assign a value to this object', debug still highlights 'Me.ReportType = Me.OpenArgs' regardless of which event I use.

any thoughts?
 

bob fitz

AWF VIP
Local time
Today, 02:50
Joined
May 23, 2011
Messages
4,731
I can't help feeling that your doing something different to what I suggested because it works for me. Take a look at the attached db.
 

Attachments

  • OpenArgToRpt.zip
    14.7 KB · Views: 114

Blackelise

aka Andrew
Local time
Today, 02:50
Joined
Jun 13, 2012
Messages
35
Thanks Bob. looks the same as mine coding wise. To help me better understand I added a new text box on yours in the header, changed the code, it worked. 'Played' a bit more all worked fine, so I understood the mechanics...

Still could not see what was wrong with mine so I deleted the text box on the report and added another one changed the code to reflect the changed object, still did not work. In frustration I decided to reboot Access2007 and bingo it works!!!!!

Guess with my 'mucking' around I must have altered something...
 

Users who are viewing this thread

Top Bottom