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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subforms do not populate linked information.

Status
Not open for further replies.

mguwc

Technical User
Mar 16, 2004
74
US
I have a form named "child data" that is a multi-tab form. The last tab is called "Case Information". This tab has a subform that is called "CDI tracking subform". This subform is also a multi-tab form. One of the tabs is called "Issues/Actions". That tab is also multi-tab with the first tab containing a subform that is in datasheet view. The subform and form are linked through a field called [CaseNumber]. When I enter information into all the forms information that is linked carries on from one form to another, except for this last form. The CaseNumber does not pass onto this datasheet. Therefore the error I get is:

The field 'ClientCallType.CaseNumber' cannot contain a null value because the required property is set to true. Please enter a value.

This is the linked field. When I go back into the design view to check to see if the master link and child link are set, the error message is then:

Object variable or with block variable not set.

I then have to delete the subform and put it back and set the links again.

I don't understand where the problem could be. Please Help.

Maria
 
In your subform, which is likely data from a table. So my suggestion is for you to go to the table of that subform and change the CaseNumber from a "required" field to No.

-Laughter works miracles.
 
Maria

Two things...
- The record set or sets is loaded when the form is loaded. New data may not appear in the subform because the underlying dataset contains old data. You can force the dataset to be updated by using the REQUERY property. REQUERY works for a combo / list box, subforms, etc.

- With referential integrity, you must create the parent record before creating the child records. The primary key must exist before it can be assigned as a foreign key on the child record.

Okay, you ask I have a simple form for the parent and a subform for the child records. How can I create the child records after creating the parent record if the dataset for the subform is not updated? I am not the expert, but I suspect that for the typical Invoice header / Invoice detail situation, Access "knows" that after creating a new parent record, it must update the recordset with the new record and pass the primary key to the subform to be used as the foreign key. This is why when creating form / subform, we have to ensure the links for the parent and child fields is set.

Your situation sounds very complicated. You may...
- be trying to create a child record without a parent
- the parent record has been created but the primary / foreign key is not available to the subform, or subform/subform.

If I was in you shoes, I would
- Ensure the parent record is indeed being created first.
- Ensure the links for the parent / child is correct
- Use the REQUERY or RECORDSOURCE + REQUERY to ensure the underlying dataset is refreshed before creating the child record.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top