S
Steve S
When I run the code below I get the runtime error "You can't assign a value
to this object" The error happens on the line labeled (A).
If I un-comment the first line of code, labeled (B) I do not get the error.
I have fought this for days and am currently running the code OK but having
to use the hokey code in line (B) bothers me. I just stumbled across this
'fix' by accident while troubleshooting the issue.
does anyone have an idea of why the error happens and a possible better
solution??
Also how sould I trap and display the error code number as well as the error
text?
----------------------------------------------------
' Me.LinkTo_ID = Me.LinkTo_ID ' (B) un-comment to stop error
intLink = 46
' Get record That may be linked
Dim db As DAO.Database
Dim rcd As DAO.Recordset
Set db = CurrentDb
Set rcd = db.OpenRecordset("Contests", dbOpenDynaset)
rcd.FindFirst "[Contest ID]=" & intLink
rcd.Edit
rcd![LinkTo ID] = [Forms]![Define Contest]![Contest ID]
Me![LinkTo ID] = intLink ' (A) error happens here
rcd.Update
Set db = Nothing
------------------------------------------------------------
to this object" The error happens on the line labeled (A).
If I un-comment the first line of code, labeled (B) I do not get the error.
I have fought this for days and am currently running the code OK but having
to use the hokey code in line (B) bothers me. I just stumbled across this
'fix' by accident while troubleshooting the issue.
does anyone have an idea of why the error happens and a possible better
solution??
Also how sould I trap and display the error code number as well as the error
text?
----------------------------------------------------
' Me.LinkTo_ID = Me.LinkTo_ID ' (B) un-comment to stop error
intLink = 46
' Get record That may be linked
Dim db As DAO.Database
Dim rcd As DAO.Recordset
Set db = CurrentDb
Set rcd = db.OpenRecordset("Contests", dbOpenDynaset)
rcd.FindFirst "[Contest ID]=" & intLink
rcd.Edit
rcd![LinkTo ID] = [Forms]![Define Contest]![Contest ID]
Me![LinkTo ID] = intLink ' (A) error happens here
rcd.Update
Set db = Nothing
------------------------------------------------------------