Parent/Child form/subform not working properly

G

Guest

Access 2003. I have a form that contains a subform. The form's recordsource
is a table called Classes and the subform's recordsource is a table called
Class Definitions. The tables are linked by the primary index in the main
table Classes. The Parent and child properties are set properly.

The problem I am having is that when I use the navigation buttons to move to
a new (empty) record in the main form. I am able to enter data in the main
form. But when I begin to put data into the subform, I am moved to what was
previously the last record in the main table. The result is that the data I
enter in the subform is not related to the new record I created, but is now
related to what was the last record in the main table.

Why is this happening? How can I fix this? Thanks and God bless.
 
B

BruceM

I watched this thread for a while to see if anybody replied. Since nobody
has, I will venture in. When you say that the tables are linked by the
primary index, do you mean that there is a ClassID PK field in the Class
table and a corresponding field (I will call it ClassID) in the
ClassDefinitions table, and that there is a one-to-may relationship between
them? Are the two ClassID fields of the same data type (e.g. Number, Text),
or if the PK field is autonumber, is the foreign key Long Integer? I take
it that the Parent and Child properties in the subform control are set to
ClassID (again, I am using the names I have given to the fields, since I do
not know what names you have used).
How are you moving to the subform? Does the main form look OK when you
first move to the subform, then jump to the previous record when you start
typing in the subform?
 
G

Guest

Dear Bruce:

The linked fileds are of same data type. The relationship is one to many.
The parent/child is set properly. I noticed that the problem started after I
went into the Class Definitions table and manually entered data (rather than
doing it from the form/subform). When I went back to the form/subform, that
is when the problem started. I cleared out all tables and made my entries
only from the form/subform and the problem did not come up. I guess that
will have to suffice for now. However, I am puzzled as to why manual entries
in the related table created the problems.
 
B

BruceM

I would think that as long as the manual entries have a foreign key field
that corresponds to the PK field in the main record it would be OK. If it
isn't I can't think why. Glad to hear you got it solved.
 
J

John Vinson

However, I am puzzled as to why manual entries
in the related table created the problems.

They would certainly cause problems (invisible data) if you entered
nothing into the foreign key field (and since this would be a
meaningless integer to link to an Autonumber, you very likely didn't
do so)!

John W. Vinson[MVP]
 

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