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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #1

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

    I'm getting a very strange error when I try to close my form. Error number -2147352567 "You can't assign a value to this object." The code that is failing is
    Code:
    Me!StatusID_fk = 112
    Part of what is so strange is that this is in the form's OnLoad event, but I got the error when I closed the form, after I had already made changes to some data on the form. I can't find this error number anywhere online, but I did find the description tied to error number 2448. The code references a field in the record source, not a control on the form.

    Something else that is really strange is that it works usually, but sometimes I do get this error and when I do, it totally locks up Access and I have to close it using the Task Manager. It is really annoying. Any ideas on how to fix this problem? I'm using Access 2010 and Access Runtime 2010.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    Seth,

    That line is the one causing the error, but it "sometimes" works? My initial thought had to do with the fact that it is in the OnLoad event, which sometimes prevents access to bound controls until after the form fully loads (thus, putting any action items into the OnCurrent Event). But, even stranger that it fires an error when you close the form....

    Even more stranger that it locks up Access.

    Have you tried commenting that line out or moving the line do a different part of your form, or forcing a manual upload (not as a permanent solution, but as a troubleshoot method to see what could be causing this)?

    It could also have to do with Access Runtime....

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      Long shot maybe, but I have had lockup situations when I mistakenly put code to save the current record if the form.dirty event was true in the BeforeUpdate event of a form or control instead of the AfterUpdate event. When triggered the application locked up, as the BeforeUpdate could not save the current record without constant retriggering in an endless loop. Took me ages to realise that the simple IF statement concerned was in the wrong event (IF me.dirty THEN me.dirty = FALSE).

      I suspect based on that experience that the issue may be some kind of event lockup associated with the changed state of the record, not the specific value of the field concerned as such. Tracing it might be quite involved if it is not happening very frequently, as you have few clues to work on when setting your watch criteria in the debugger, say.

      -Stewart
      Last edited by Stewart Ross; Mar 11 '15, 08:12 PM.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        You came close Stewart. I was changing the status of the record, but the underlying query doesn't pull the new status records so I was basically excluding it from the recordset. I'll have to play around with that. Thanks for triggering my brain.

        Comment

        Working...