You Can't Assign Value to This Object (Subform) (1 Viewer)

Solo712

Registered User.
Local time
Today, 02:38
Joined
Oct 19, 2012
Messages
829
Thought I would share a little discovery I have made after some have-duty wall climbing. You will find dozens of Access forum entries dealing with the above Access message (Runtime Error 2448) and a good portion of those deal with the specific issue of it appearing when starting data entry in subforms. The message says :

You can't assign a value to this object.
*The object may be a control on a read-only form.
*The object may be on a form that is open in Design View
*The value may be too large for this field.

But in reality, once you clear the message (which pops after the first letter was entered), shaking your head because none of the above applies, you are allowed to continue and the record is saved without further complaints or ceremonies and it links correctly and can be edited on further visits.

I have decided to redo my memo fields in one of my databases and place them all in one separate table. The memos are then attached as subforms. I created a pointer field in each of the tables as a master field to link by with a subform. On a couple of occasions prior, I created such a field to easily sort by a unique composite key. Never had any problems using it with subforms. However, in this particuar instance it started to give me this silly message. I say 'silly' because it is transient and says something that is not true. Evidently, you can assign value to this object (in this particular scenario).

First I thought it had to do with the rich text fomat that I have in the Memos (the RTF does not work in Access 2007 subforms but that's another story). But it didn't. So I tried other things and they did not work. Always the same thing. After the first letter typed the message popped up.

I hope I found the solution to this particular form of the 2448 RTE. On one of the boards someone was saying that the master field has to the PK of the main form. I knew that was baloney because I have a number of forms where I use another (unique) key for the master-child coupling with no trouble at all. But then I realized what might be happening. The autonumber of the master form would be supplied early by the Jet/Ace engine and so is available to the before the sub is entered. One can start writing into the sub fields right away and switch to the main form with the record being saved because the link has already been established by the engine coupling. That would not be ....duh.! :rolleyes:... the case when I am supplying the value myself. So it looks like the value of the master - child fields has to be known to both forms before the first stroke hits the subform. Does that make sense ? If it does, then

perhaps a fourth line should be on the Access message saying:

* The object may be on a subform with a Null in the linked Master Field

Hopefully, this info will be of some value to people on this Board. Initializing the subform with the linking key solved the problem for me. At any rate, let me know your thoughts!

Best,
Jiri
 

CJ_London

Super Moderator
Staff member
Local time
Today, 07:38
Joined
Feb 19, 2013
Messages
16,600
subforms load before the main form, so I have come across this problem myself in the past

The way I have resolved it is set the subform control sourceobject to nothing so when the mainform loads it does not load the subforms.

Then in the main form oncurrent event I simply assign the subform name to the subform control sourceobject.

You can get whitespace for a fraction of a second -depends on the processor but solvable by setting th subfrom visible to false in the design and then setting to true once you have assigned the recordsource in the current event.

The other potential benefit of doing this is that with proper design it can cutdown network traffic because you would modify the recordsource to filter on the field required and not use the master and child fields.

You would be surprised how often the subform events can fire before the main form opens - here is a recent analysis I did - check out the Memo events which is the same as we are discussing here (a table of memo fields in a subform on the member form linked on a non PK field using master and child linking)
Existing
Memoopen
Memoload
Memocurrent
Sharedopen
Member Open
Member load
Member current
Memocurrent
Memocurrent
Memocurrent
Member current
Memocurrent
Memocurrent
Memocurrent
 

Solo712

Registered User.
Local time
Today, 02:38
Joined
Oct 19, 2012
Messages
829
subforms load before the main form, so I have come across this problem myself in the past

The way I have resolved it is set the subform control sourceobject to nothing so when the mainform loads it does not load the subforms.

Hi CJ,
thanks for replying. This particular problem (RTE 2448) does seem to originate in the loading sequence. The screen needs to be fully rendered for the data error to occur. You may remove the Source Object but you need not do that if you initialize the master and child fields of the subform in the OnCurrent Event. Then the user can enter the subform of a new record without getting the error message. At least, that's my theory.

What I would really like to know is if anyone has seen this error with autonumbered PK in the master field.

Best,
Jiri
 

InstructionWhich7142

Registered User.
Local time
Today, 07:38
Joined
Feb 24, 2010
Messages
199
Me!

:Master table on Main form with primary key (creatively called ID) set as the Link Master Fields, Link Child Fields set to a field in the subform's control source (which is defined in the database relationships with referential integrity enforced to ID) when I add the first new record via this subform i get this error, any subsequent new records dont give this,

I have a second subform on the same Main form, this one uses a listbox as its Master, I get the same error when I type into a new record this form ffirst,

However once i have had the error once from either subform everything works fine and the other subform will not give the error on the first opening.

I have tried:
Me.clProbP.SourceObject = "clprobp"

Me.clProbC.SourceObject = "clprobc"
Me.clProbC.LinkMasterFields = "List152"
Me.clProbC.LinkChildFields = "ID"
in my Main form's on current event and I can still get the errors
 

Users who are viewing this thread

Top Bottom