How to assign value to a report control?

G

Guest

I have a unbound report control. The value will be extracted from a table and assign to this control when the report is open. In form, we can code me!controlname. I tried the same but got run-time error "2448" - You cannot assign a value to this object.

Please help.
 
R

Raghu Prakash

Hi Peter,

About setting the value of a control or property in response to an event
By assigning new values to controls (control: A graphical user interface
object, such as a text box, check box, scroll bar, or command button, that
lets users control the program. You use controls to display data or
choices, perform an action, or make the user interface easier to read.) and
properties in response to events (event: An action recognized by an object,
such as a mouse click or key press, for which you can define a response. An
event can be caused by a user action or a Visual Basic statement, or it can
be triggered by the system.) that occur on a form or report, you can make
the objects you've created work together so that they're easier to use.

Here are some common situations that call for setting values with a macro
(macro: An action or set of actions that you can use to automate tasks.) or
an event procedure (event procedure: A procedure that is automatically
executed in response to an event initiated by the user or program code, or
that is triggered by the system.):

Setting the value of a control on one form equal to the value of a control
on another form

For example, you can put an Open Orders command button on a Customers form
that opens an Orders form and automatically fills in billing information
from the Customers form.



Clicking the Open Orders button opens the Orders form with the billing
information from the Customers form.

Updating the value of a control that's dependent on the value of another
control

For example, you might have a PaymentDate control whose default value is
the ship date (the value of the ShipDate control). You can use a macro or
an event procedure to automatically reset the value of the PaymentDate
control whenever the value in the ShipDate control changes.

Setting a form or control property in response to a selection or other event

You can use a macro or an event procedure to set a form or control property
in order to:

Hide or display a control based on the value of another control. For
example, you might want the DateDue control on an Orders form to be hidden
if the order is already paid for (if the Paid control's value is Yes) or
visible if payment is still due.
Disable or lock a control based on the value of another control. For
example, you can disable a DriversLicense control if the value of an Age
control is below the minimum age for a driver's license.
Display different sets of records depending on a selection. For example,
you can control which records are displayed in a Customers form, depending
on which option is selected in a Customer Type option group.


http://office.microsoft.com/assistance/preview.aspx?AssetID=HP051866361033&C
TT=1&Origin=EC790000701033&QueryID=V7f5eH1wW0&Query=About+setting+the+value+
of+a+control+or+property+in+response+to+an+event&Scope=TC%2cHP%2cHA%2cRC%2cF
X%2cES%2cEP%2cDC%2cXT

Please let me know has this helped You...
Thank you...
Raghu...
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

david epsom dot com dot au

You probably want a label. In the code, you can put me.lblName.caption =
strText
You can do that at start up or every time you format a section.

Bound Text Boxes can't be changed after startup. You have to bind them to
something that changes.
For example, you can bind them to a field in your recordsource. Or to a
function "=myfunc(report.fldID)". or whatever.


(david)




Peter said:
I have a unbound report control. The value will be extracted from a table
and assign to this control when the report is open. In form, we can code
me!controlname. I tried the same but got run-time error "2448" - You cannot
assign a value to this object.
 

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

Top