You can't assign a value to this object

StuckfromPR

Registered User.
Local time
Yesterday, 22:12
Joined
Sep 15, 2008
Messages
18
Hello,

I am getting the following error while trying to put a value of a form into a text box of a Report.

You can't assign a value to this object

This is the code

Dim strId As String 'Variable to take data from a form

strId = Forms!Form1!EID_drp.Value 'Getting values from a drop down in Form1

txtName.Value = strId 'Passing the value to a text box.
 
I would venture to first guess that the value you are getting isn't the same data type as your declared variable.

You declare a string and might be trying to assign a number (the bound field of the drop down box). First check would be to verify the bound column of the drop down box.

I don't know the parameters of your drop down box, but assuming if it's an ID, the bound column is on the ID (a number field), but the presented column to the user is a string. Futher assuming the ID is column 1 and the Text is column 2 then you would want to use ....

Code:
strId = Forms!Form1!EID_drp.Column(2)

Again, just a guess.

-dK
 
That wasn't it. It is saying that the text box is the one who can't take the value.
 
Ah. Hmmm.

Is the control on the report unbound? Is the form open behind the report?

If so you should be able to dismiss the variable and just reference it directly ....

Code:
txtName.Value = Forms!Form1!EID_drp.Value

-dK
 
I just ran a test to make sure ...

I had an unbound control on the report and in the control source put in ..

Code:
=[Forms]![frmMain]![cboTest]

This pulled over the value from the bound column of the combo control on form main. I am not sure where you are telling it to do this from hence the this control = that control in the previous post.

Again, this is possible because the form is still open behind the report, hence the question.

-dK
 
I had this error - it was caused by the form's on_open event trying to set a field value. i moved the code to the on_load event to solve it. For the record, the line was:
BeingEditedYN = "Y"
 

Users who are viewing this thread

Back
Top Bottom