Blank subforms

M

Miaplacidus

I have a form with two subforms. The subforms are linked
to the main form via IDNO. When I enter a new record on
the main form the two subforms appear as blank records in
order to enter the related data.

I have another form with the same setup, except now the
mainform is itself a subform. When I try to enter a new
record in this view the two subforms (now subsubforms)
appear without any fields, labels, lines etc. All I see is
the area where the form is supposed to be with the
background properly colored. If the form is located at an
existing record the the subforms appear as normal.

???
 
M

MacDermott

Until the data in a new record in the main form is saved, there is nothing
for the subform to link to, so it shows up as blank.
You might want to save the record (Me.Dirty=False is one way to do it) in
the AfterUpdate of IDNO.

HTH
- Turtle
 
M

MacDermott

You wrote:
"I can look at a form/subform record in one view of my
database and it is properly and completely filled in.

If I look at this same record in another view of the
database (the previous form/subform is itself a subform in
this view) then the subform records appear as a blank
(colored) screen area within the main form."

Let's see if I have this straight:
(I'm assuming forms based on tables; I'd still start in the same place for
queries, but there would be more questions.)
FormA is based on TableA.
FormB is based on TableB.
FormC is based on TableC.

You have a record in TableA, with a non-null value in the Foreign Key.
You have a record in Table B, with a Primary Key matching the Foreign Key in
Table A,
and a separate Foreign Key in TableB with a non-null value in it.
You have a record in Table C, with a Primary key matching the Foreign Key in
Table B.

Is all of the above true, or do you have some nulls or missing records in
there?
And are you using tables or queries?

- Turtle
 
M

Miaplacidus

I guess I'm not too sure about foreign key terminology.
Tables A, B, and C all have a Primary key. The tables are
linked with referential integrity enforced. As I
understand it this means that the foreign key in table a
is the same as the Primary key. Tables B and C are each
linked directly to A, therefore there is no foreign key in
C that matches B. Both B and C match A. There is no
Primary key in B and C, only the foreign Keys.

I have solved part of the problem, but I have no idea how.
Previously it was possible to look at a completed record
on one form but the subrecords on the other form were not
only blank, but no fields were showing on the subform.
That problem has gone away.

Here is the current (related?) problem. I have two forms
based on A, B, and C. B and C are subforms to A. On the
second form A (with B and C subforms) is itself a subform,
that main form is recursively related to A. A is a list of
employees and the main form is employees who are
supervisors, therefore the Employee IDNO in the main form
is linked to the ReportsToIDNO in Form A.

The supervisors form is based on a query, otherwise the
forms are based on tables. If I open form A(BC) and go to
the end of the file (the * record) a new blank record
appears with associated blank records for B and C. This
way I can enter a new record(s) for all three tables and
they all synchronize automatically because of referential
integrity.

I copied form A(BC) and put it on the supervisors form
linked ReportsToIDNO to IDNO. Now, if I go to form A and
proceed to the last record (*) I would expect to be able
to enter a new subordinate employee. I can do this, but
now the subtables (B and C) show simply as colored
squares where the subforms should be. If I back up to any
previous (completed) record, the subforms behave normally.

Why does this form, which is a copy of one that works, not
work when it is a subform itself?

(I was formerly a Paradox user where keys are entirely and
transparently handled by the software, so I never learned
this foreign key stuff very well.)
 
M

MacDermott

Let's take the ubiquitous case of and Orders table and an OrdersDetail
table.
Orders has customer, date, shipVia, etc.
Each record in OrdersDetail is one item on the order, e.g. Item="Red
Pencil", Qty=3, UnitPrice= $.50.
Each record in OrdersDetail must also contain a field which references the
Orders table, so that we can know which Order that detail goes with.
So each record in Orders needs a Primary Key, which uniquely identifies that
record.
Each record in OrdersDetail contains a ForeignKey field, which identifies
the Order it belongs to, by containing the Primary Key of that record.
Does OrdersDetail also require a Primary Key? Logic may say it doesn't, and
Access does permit you to build a table without a Primary Key, but
experience says things will work much better if each table has a Primary
Key. Just add an autonumber field, and you may find your problems go away.
(No promises, though.)

Now I'm re-reading your post:
First, you say Tables A, B, and C all have a Primary Key.
Then at the end of the same paragraph you say there is no Primary key in
B and C, only the Foreign Keys.
This confuses me.

Also -
How is INDNo assigned? Is it an autonumber?
Are subforms B and C linked to A using INDNo?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top