Linked form vs. Subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My apologies if this question has been asked and answered previously (I did
search!):

I have two tables that are related via a one-to-many relationship. I would
like to create a system for data entry into these tables. I've created a
main form for my "one" table. When I create a subform out of my "many"
table, I am able to enter data that saves correctly in the database.
However, when I create a linked form out of my "many" table, I get an error
message:

"You cannot add or change a record because a related record is required in
table 'NAME'"

I would much prefer to use a linked form if this is possible. Can someone
help me with this?

Thanks in advance,

Joe
 
Joe said:
My apologies if this question has been asked and answered previously
(I did search!):

I have two tables that are related via a one-to-many relationship. I
would like to create a system for data entry into these tables. I've
created a main form for my "one" table. When I create a subform out
of my "many" table, I am able to enter data that saves correctly in
the database. However, when I create a linked form out of my "many"
table, I get an error message:

"You cannot add or change a record because a related record is
required in table 'NAME'"

I would much prefer to use a linked form if this is possible. Can
someone help me with this?

An embedded subform automatically forces the creation of a parent before a
related child record can be created and it also automatically propogates the
linking field values to the child records. As long as you do all of that
yourself a non-embedded form can be used for the Child records.

If you have a button on the main form that will open the "linked" form then
tha code behind that button should issue a save to the current parent record
before opening the other form and it should only allow the other form to
open when the parent form is positioned on a proper record (not on the new
blank record position).

Dim OpnFrm as Boolean
If Me.NewRecord = True Then
If Me.Dirty = True Then
Me.Dirty = False
OpnFrm = True
End If
Else
OpnFrm = True
End If

If OpnFrm = True Then DoCmd.OpenForm ...

You can then set the default value properties for the second form's fields
that represent the relationship between the two tables so that it pulls
those values from the parent form.

=Forms!MainFormName!FieldName
 
Back
Top