Problem with Child-Master when Adding New Record

  • Thread starter Thread starter David T
  • Start date Start date
D

David T

Hello,



I have forms that are reacting differently in my DB.



Form frmORDERHEADER (query) and subform

frmORDERLINES share 2 common fields from 2 separate queries the fields are
fldOrdernum and fldBackOrdernum.



I have made the Master / Child relationship and it works great until I try
to add a record to the subform.



fldOrdernum and fldBackOrdernum on the Subform remain blank. There are no
default values anywhere.



Also I am doing the same with Purchase orders and it works perfectly. The
differences are:

The one that works only has 1 field to match on the Main and Sub Form.

Also, the field is TEXT on the one that doesn't work and LONG INTEGER on the
one that does work.



Any ideas or suggestions?



Thanks



David
 
If I understand you correctly you have a form and a subform, both based on
queries. The LinkMasterFields contains 2 field names, and so does
LinkChildFields. The 2 fields named in LinkChildFields remain blank when you
add a new record in the subform, when you would expect Access to
automatically give them the values of the fields in the main form.

It would be a good idea to cancel the BeforeInsert event of the subform,
just to make sure that this is not being caused because the main form is at
a new record when the child record is created (which would, of course, give
you null foreign keys.)

Do you have controls (text boxes) for fldOrdernum and fldBackOrdernum in the
subform? If not:
1. Delete the LinkMasterFields and LinkChildFields entries, and save.
2. Add the 2 text boxes (Visible = No if you wish).
3. Enter the LinkMasterFields and LinkChildFields again.

If that does not sort it out:
a) Do the 2 fields match exactly, i.e. same type (TEXT) and size (50 char or
whatever)?

b) Have you created a relation with Referential Integrity enforced, based on
the combination of the 2 fields in the same order as specified in
LinkMasterFields/LinkChildFields?

c) Is Name AutoCorrect off (Tools | Options | General), so Access can't get
the associations wrong?

d) Is there any way that Access could misunderstand the data type or size of
these fields (e.g. if there are calculated fields in the
LinkMasterFields/LinkChildFields.)

A workaround would be to use the BeforeInsert event of the subform to assign
the values yourself. However, it should not be necessary to do that.

If you are still stuck, please indicate the version of Access where this
happens, and the version of msjet40.dll (typically in windows\system32)
 
Back
Top