Re: Linked Form Not Allowing New Records



Hey Rick. Thanks for the advice. I didnt realize that about linked
forms. Its hard for me to describe what Im working on because I cant
talk about the data but I actually started with linked forms because I
have too many subforms to fit on one main form and be usable. Are
there any other options Im not thinking of as far as subforms? I want
to make this as user friendly as possible and the linked forms
definitly work better for what I have.

Rick Brandt wrote:
Rob wrote:
I have a one to many relationship between two tables: tblCars and
tblParts (One car can have many parts). I created a form using the
wizard and chose "linked forms" instead of "form with subform" when
prompted. The problem Im having is that when entering new records in
the linked form it does not capure the "linked" field from the main
form which causes an error message which reads "Index or primary key
cannot contain a null value". I know access is supposed to "autofill"
that field but its not working. Whats more frustrating is that it
works fine for existing records. I only have a problem during data
entry. Any ideas?

No, Access is only supposed to autofill that field if you choose to build a
form with a subform. Linked forms do NOT provide that feature. All it does
is provide a filter for EXISTING records exactly as you are seeing.

You can solve the problem by setting the DefaultValue property of the second
form to a reference of the first form...

=Forms!FirstFormName!LinkingFieldName

That will mean that you can only use the second form when the first is open
and if you open the second form, navigate to a new record, and then navigate
to a different record on the first form before you fill out the new record
on the second form the new record will still have the linking field from the
record on the first form when it was originally opened. As you can see the
linked form is not as robust as a real subform in this regard. Code can be
added to both forms to solve some of these issues.

You can also make the second form modal so that you have to close it before
you can go back to the first form and change the record on that.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

.



Relevant Pages

  • Re: Opening a form to a specific record
    ... Rick ... I am attempting to open the second form and ... > display a specific record based upon the display value of a multicolumn ... > the code from the command button's click procedure on the first form: ...
    (microsoft.public.fox.vfp.forms)
  • Re: Linked Form Not Allowing New Records
    ... Consider using a tab control and putting a subform on each tab. ... That will mean that you can only use the second form when the first is ... record on the first form when it was originally opened. ... Rick Brandt, Microsoft Access MVP ...
    (microsoft.public.access.forms)
  • RE: Requerying form 1 after creating new record in form 2
    ... After doing a lot more digging in these forums, I found the answer, and ... I automatically opened a second form to enter new records. ... get the second form record to save and b) could not get the the first form to ... then be able to populate the appropriate bound control in frmLast_Updated. ...
    (microsoft.public.access.formscoding)
  • RE: Carrying a field value to another form
    ... Pass the first form's key in the OpenArgs argument of the OpenForm method. ... Refer to a control on the first form to obtain the value. ... I suggest the BeforeInsert event because it fires immediately after the ... > record passed to the second form to select the same record for updating. ...
    (microsoft.public.access.forms)
  • Re: Linked Form Not Allowing New Records
    ... That will mean that you can only use the second form when the first is open ... and if you open the second form, navigate to a new record, and then navigate ... record on the first form when it was originally opened. ... linked form is not as robust as a real subform in this regard. ...
    (microsoft.public.access.forms)