Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error msg:You can't assign a value to this object

Status
Not open for further replies.

ctudose

Programmer
Nov 22, 2001
33
0
0
CA
I have a function that takes an Int returns an Int after calculation

Public Function OutputDelivered(ProjectID As Integer) As Integer

On a form I have 3 controls : R1,[Proposal Traking Number] and the last one [Output_Delivered]

In R1_AfterUpdate event , i try to call the function
code:

Private Sub R1_AfterUpdate()
Me.Refresh
Me.Output_Delivered = OutputDelivered(Me.[Proposal Tracking Number])
End Sub

the form is NOT read-only, controls are editable, BUT
i've got this error message :

"Run-time error '2448' : You can't assign a value to this object"

if I call like this no error message:
Me.Output_Delivered = OutputDelivered(123)

any suggestion would be much appreciated
thx,
c.
 
Me.Output_Delivered = OutputDelivered(Me.[Proposal Tracking Number])

When using a dot . the code is referring to the object itself NOT the value contained by the object. To resolve this problem one of two solutions apply

Solution One

Me!Output_Delivered = OutputDelivered(Me![Proposal Tracking Number])

OR

Me.Output_Delivered.value = OutputDelivered(Me.[Proposal Tracking Number].value)

In both cases I have change the reference to the value contained by the object instead of teh object itself.

It does not matter which way you use, but pick one and use it consistantly it will help you in reading your code.

 
Hi ssecca,

same result with
Me.Output_Delivered.value = OutputDelivered(Me.[Proposal Tracking Number].value)

why if i pass the value like this , it's ok
Me.Output_Delivered = OutputDelivered(123)

any further suggestions ?
cris

 
Hi there,

About a month ago you entered the above problem with not being able to assign a value.

Did you get a workaround?

I am having the same problem.

Thanks!
 
response for zionman4

what i've done :
i have a recordset rs with 1 record
before I had :

Public Function OutputDelivered(projectid As Integer) As Integer
....

With rs
....
OutputDelivered=value
End With

End Fuction


and I modified the code like this


Public Function OutputDelivered(projectid As Integer) As Integer
....

If Not (rs.BOF Or rs.EOF) Then
.....
OutputDelivered = value
End If

End Fuction

and it WORKED !!
I don't know if this is your situation.
Good luck!
Cris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top