scope of variables/controls between objects

jguscs

Registered User.
Local time
Today, 10:49
Joined
Jun 23, 2003
Messages
148
I've got a report that, upon opening, opens a form:

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "TableChooser", acNormal, , , acFormPropertySettings, acDialog, ""
End Sub

In the form are 2 combo boxes (one that chooses the record source for the report, the other sets a value of a control in the report.
In the form are also 2 command buttons (OK and cancel).
When OK is pressed:

Private Sub OK_Click()
Reports![Equipment Profile].RecordSource = ComboTable
Reports![Equipment Profile]!EPState = ComboState
DoCmd.Close
End Sub

The program works with the code:
Reports![Equipment Profile].RecordSource = ComboTable
But when the code
Reports![Equipment Profile]!EPState = ComboState
is inserted, there is an error that says "You can't assign a value to this object".
What's wrong?
 
I've discovered a workaround (even though I don't like workarounds):

What I'm trying to do is set the value of a text box in an object (report) other than the active one (form).

What I did was set the .Caption value of a label in the report from the form. That has the same effect of changing the value of a text box. But doing this actually works.

Still, if anyone has any idea how to do what was proposed in my first post in this thread, please let me know. Thanks.
 

Users who are viewing this thread

Back
Top Bottom