Re-opening subform shows no records

  • Thread starter Thread starter Jacques
  • Start date Start date
J

Jacques

Hi all,
I thought I saw a similar problem posted but I'm unable to find it.

I have a form with a command button that calls another form.
The subform properly filters and only shows the related records,
but when you close it, and re-open it, it says there are no related records.

I checked the table the subform is bound to, and the field that has the main
table's PK
is empty for every record entered by the subform (though the other fields
have the entered data).

How do I get my subform to make sure the related PK (from the main
form/table) field is filled in properly
when entering data through the subform?

I appreciate any help.

Thanks,
Jacques
 
Jacques,

The first thing to check is the setting of the Link Master Fields and
Link Child Fields properties of the subform.

Well, that is if it really is a subform. I was not clear about your
post, because as well as a subform, you also mentioned about a separate
form which is "called" by a command button, so I don't understand this.

If you are indeed entering records in a separate form, then how is your
database application supposed to "know" which value to enter in the
field which seems to be empty? Unless you enter the data yourself, that is.

So, in summary, can you please give a little more detail about your
forms and data? Thanks.
 
Steve,
My apologies for not being more clear.

I have TableA, TableB, and TableC with A having a 1 to many relationship
with B, and B to C.

I made FormA, FormB and FormC seperately.

I then placed a command button in FormA to call FormB and used the Wizard to
connect (and filter) the records FormB would show (based on what record in
FormA was highlighted).

The filter works fine with FormA calling FormB, as well as B to C, but
adding records through those forms doesn't give them the corresponding key.
 
Jacques,

Ok, thanks for the clarification.

If you could use subforms, it would solve the problem. For example, if
you embed FormB on FormA as a subform, the foreign key field in FormB
can automatically be populated with the value of FormA's primary key field.

Otherwise, you will have to use macro or VBA procedure to assign the
required value. One approach would be to use FormB's Before Insert
event, with code along these lines...
Me.ForeignKeyField = Forms!FormA!PrimaryKeyField
 
Thanks Steve,
Appreciate the help.


Steve Schapel said:
Jacques,

Ok, thanks for the clarification.

If you could use subforms, it would solve the problem. For example, if
you embed FormB on FormA as a subform, the foreign key field in FormB can
automatically be populated with the value of FormA's primary key field.

Otherwise, you will have to use macro or VBA procedure to assign the
required value. One approach would be to use FormB's Before Insert event,
with code along these lines...
Me.ForeignKeyField = Forms!FormA!PrimaryKeyField
 
Back
Top