Home > Net >  ms access: 'cannot assign value to this object' message, but assigning value works anyway
ms access: 'cannot assign value to this object' message, but assigning value works anyway

Time:07-19

I have a strange issue with one of my data entry forms. I have a main form from which I open said data entry form using a button. Once the form is open, I can enter a new record (the DE-form is set to allow additions and data entry is set to YES). The first time AFTER opening the main form, and only the very first time (subsequent tries work as intended), when opening the DE-form from the button and attempting to enter new data into the field "Bezeichnung", I get the following error message:

You can't assign a value to this object.

error message

The weird thing comes now. After clicking OK in the dialogue box, in spite of what the message just indicated, the field contains the character I had just entered and allows me to continue adding data without issue.

works despite error 1

After adding the new record and confirming, it shows up on my main form, as well as the related table, as intended. I have tried making a new DE-form from scratch but encountered the same thing. The message only pops up the very first time I attempt to enter new data via the DE-form after opening the main form. Opening the DE-form a second or third time while the main form is still up does not result in the same message. Also, it's the same with any of the fields on the DE-form, not just the first one. After the message pops once, it never shows up again until I close the main form. This is the only DE-form in my project that has this issue, I can#t seem to figure out why. Any help is appreciated.

Database Structure:

DB relationships

Details of my data entry form:

*The DE-form consists of a form with a subform on it (white box in the middle). I have other forms where this is neccesary and in order to keep the design consitent I opted to do the same with this one. Both forms have an invisible textbox bound to stoff_id. The DE-subform has Link Master Field and Link Child Field set to stoff_id

Recordsource DE-form main

SELECT chemikalien_tabelle.stoff_id
FROM chemikalien_tabelle;

Recordsource DE-form sub

SELECT chemikalien_tabelle.stoff_id, chemikalien_tabelle.bezeichnung, chemikalien_tabelle.einsatzgebiet, chemikalien_tabelle.kategorie_id
FROM kategorie_tabelle INNER JOIN chemikalien_tabelle ON kategorie_tabelle.kategorie_id = chemikalien_tabelle.kategorie_id;

CodePudding user response:

I found a solution on another site. Apparently, what is causing the message is an invisible textfield bound to the primary key stoff_id (which is AutoValue) of chemikalien_tabelle on the DE-subform. I usually add the primary key somewhere to my forms since it is likely I will need it. I still don't know why this issue popped up though. The original answer I am refering to did not either Foreign Solution. The post is in German, so check it out at your discretion. Removing the textbox fixes the issue but without it I cannot assign a completely new record. I have a number of other data-entry forms that have the same setup, so I am not sure why this only caused issues in this particular case. Maybe someone else has a an idea?

  • Related