"You can't assign a value to this object."

B

Bob Barnes

Is Error -2147352567

Have code trying to populate aun unbound text box on "Report_Open".

The code starts like...
Private Sub Report_Open(Cancel As Integer)
Select Case Forms![frm_Emission Calculations]!cboMonth
Case 1
TheMonth = "JAN"

In this Case, Forms![frm_Emission Calculations]!cboMonth = 1...the code
fails at
TheMonth = "JAN"

Ideas?

TIA - Bob
 
R

Rob Parker

Interesting - I would have expected that to work (as you did). And I don't
know why it doesn't; perhaps one of the MVPs could help with that.

Meanwhile, a workaround is to change your unbound textbox control to a
label, and assign the string to the caption property:
....
Case 1
TheMonth.Caption = "JAN"
....

HTH,

Rob
 
B

Bob Barnes

Rob - That did it.

THANK you.

Bob

Rob Parker said:
Interesting - I would have expected that to work (as you did). And I don't
know why it doesn't; perhaps one of the MVPs could help with that.

Meanwhile, a workaround is to change your unbound textbox control to a
label, and assign the string to the caption property:
....
Case 1
TheMonth.Caption = "JAN"
....

HTH,

Rob


Bob Barnes said:
Is Error -2147352567

Have code trying to populate aun unbound text box on "Report_Open".

The code starts like...
Private Sub Report_Open(Cancel As Integer)
Select Case Forms![frm_Emission Calculations]!cboMonth
Case 1
TheMonth = "JAN"

In this Case, Forms![frm_Emission Calculations]!cboMonth = 1...the code
fails at
TheMonth = "JAN"

Ideas?

TIA - Bob
 
M

Marshall Barton

It doesn't work because the Open event is too soon to assign
control values. Value assignments need to be done in a
section's Format event.

In this case a lable is more appropriate than a text box, so
that was the best answer regardless of why it wouldn't work.
--
Marsh
MVP [MS Access]


Rob said:
Interesting - I would have expected that to work (as you did). And I don't
know why it doesn't; perhaps one of the MVPs could help with that.

Meanwhile, a workaround is to change your unbound textbox control to a
label, and assign the string to the caption property:
...
Case 1
TheMonth.Caption = "JAN"


Bob Barnes said:
Is Error -2147352567

Have code trying to populate aun unbound text box on "Report_Open".

The code starts like...
Private Sub Report_Open(Cancel As Integer)
Select Case Forms![frm_Emission Calculations]!cboMonth
Case 1
TheMonth = "JAN"

In this Case, Forms![frm_Emission Calculations]!cboMonth = 1...the code
fails at
TheMonth = "JAN"
 
B

Bob Barnes

Marsh,

Thank you.

Bob

Marshall Barton said:
It doesn't work because the Open event is too soon to assign
control values. Value assignments need to be done in a
section's Format event.

In this case a lable is more appropriate than a text box, so
that was the best answer regardless of why it wouldn't work.
--
Marsh
MVP [MS Access]


Rob said:
Interesting - I would have expected that to work (as you did). And I don't
know why it doesn't; perhaps one of the MVPs could help with that.

Meanwhile, a workaround is to change your unbound textbox control to a
label, and assign the string to the caption property:
...
Case 1
TheMonth.Caption = "JAN"


Bob Barnes said:
Is Error -2147352567

Have code trying to populate aun unbound text box on "Report_Open".

The code starts like...
Private Sub Report_Open(Cancel As Integer)
Select Case Forms![frm_Emission Calculations]!cboMonth
Case 1
TheMonth = "JAN"

In this Case, Forms![frm_Emission Calculations]!cboMonth = 1...the code
fails at
TheMonth = "JAN"
 
R

Rob Parker

Thanks for that, Marsh. Another little tid-bit to be filed away in my
(sometimes rather forgetful) memory.

Rob

Marshall Barton said:
It doesn't work because the Open event is too soon to assign
control values. Value assignments need to be done in a
section's Format event.

In this case a lable is more appropriate than a text box, so
that was the best answer regardless of why it wouldn't work.
--
Marsh
MVP [MS Access]


Rob said:
Interesting - I would have expected that to work (as you did). And I
don't
know why it doesn't; perhaps one of the MVPs could help with that.

Meanwhile, a workaround is to change your unbound textbox control to a
label, and assign the string to the caption property:
...
Case 1
TheMonth.Caption = "JAN"


Bob Barnes said:
Is Error -2147352567

Have code trying to populate aun unbound text box on "Report_Open".

The code starts like...
Private Sub Report_Open(Cancel As Integer)
Select Case Forms![frm_Emission Calculations]!cboMonth
Case 1
TheMonth = "JAN"

In this Case, Forms![frm_Emission Calculations]!cboMonth = 1...the code
fails at
TheMonth = "JAN"
 

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