Hi Crystal -
Thanks for the reply. Unforturnately, the value that I'd like to assign to
the report textbox control isn't on a form; it's generated programmatically
in the code of a button's Click event procedure. In the code I provided
previously, I tried unsuccessfully to assign the string value "Invoice"
directly to the report textbox (Reports!StandardInvoice!BIType).
I've therefore modified my approach to pass the value "Invoice" from the
button_Click event procedure to the report's Open event procedure (as you
suggested) using the OpenArgs arguement of the OpenReport method as:
--------------------------------------------------------------------------------------------------
Private Sub btnBillToAccount_Click()
'When this btn is pressed, set s_label to "INVOICE"
s_label = "INVOICE"
'Pass s_label to the report open event as OpenArgs arguement of OpenReport
method
DoCmd.OpenReport "StandardInvoice", acViewPreview, , "[JobID]=" & [JobID],
, s_label
End Sub
--------------------------------------------------------------------------------------------------
So far, so good. The value is passed correctly to the following Report_Open
event, but I get the error message "You can't assign a value to this object."
when the event fires:
--------------------------------------------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
'BIType is the name of the textbox control on the report
Me.BIType = Me.OpenArgs <----------- ERROR OCCURS HERE.
End Sub
--------------------------------------------------------------------------------------------------
Note: when the error occurs, Debug shows that the value of Me.OpenArgs is
correct ("INVOICE"). So, I suspect that my syntax for referencing the BIType
textbox control (Me.BIType) is wrong or I'm trying to do something out of
context.
--
Jay
strive4peace said:
Hi Jay,
if the BIType control on your report gets its value from a form, use
this for the ControlSource in the report
=Forms!Formname!controlname
when you are assigning a controlsource, don't forget to start with an
equal sign and include delimiters, "='Invoice'"
....but I believe assingments need to be made from the design view or
code behind the report on open
Warm Regards,
Crystal
*
have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
In the following event procedure, I'm trying to set the value of a report
textbox named 'BIType' to the string value "Invoice" when the report is
previewed. The report previews just fine when the button btnBillToAccount is
pressed, with the exception that the textbox BIType on the report is blank.
Why doesn't textbox BIType display the string "Invoice" ?
Private Sub btnBillToAccount_Click()
On Error GoTo Err_PreviewInvoice_Click
DoCmd.OpenReport "StandardInvoice", acViewPreview, , "[JobID]=" & [JobID]
Reports!StandardInvoice!BIType = "Invoice"
Exit_PreviewInvoice_Click:
Exit Sub
Err_PreviewInvoice_Click:
MsgBox Err.Description
Resume Exit_PreviewInvoice_Click
End Sub