SUBFORM - AUTO POPULATE PRIMARY KEY

L

-LWG-

Main Form: School
Subform: Courses (1 to many from School)
Subform2: Sites (1 to many from Courses)

Everything works fine when the form and both subforms are displayed. When I
add a record to subform2 the Courses ID auto-populates which I want.

However, when I open Subform2 from an action button and click add record,
the Course ID does not auto-populate.

Help?

Thanks...
 
J

John W. Vinson

Main Form: School
Subform: Courses (1 to many from School)
Subform2: Sites (1 to many from Courses)

Everything works fine when the form and both subforms are displayed. When I
add a record to subform2 the Courses ID auto-populates which I want.

However, when I open Subform2 from an action button and click add record,
the Course ID does not auto-populate.

Help?

What's the Recordsource of each form? Post the SQL. Why should CourseID
autopopulate, if it's not (part of) the master/child link field?
 
R

Ron2006

Reason is simple.

I has NO idea what course ID to use since it is not a child of
anything when you open the form independently.

If sites is really independent of courses and/or School, then it
should be a separate table of JUST sites and what you select in form 2
should be a table that contains the courseID and the selected Site id.

If site is entirely dependent on course then it should never be
created except in a situation where the system can know what course is
involved.

Ron
 
J

John W. Vinson

Reason is simple.

I has NO idea what course ID to use since it is not a child of
anything when you open the form independently.

If sites is really independent of courses and/or School, then it
should be a separate table of JUST sites and what you select in form 2
should be a table that contains the courseID and the selected Site id.

If site is entirely dependent on course then it should never be
created except in a situation where the system can know what course is
involved.

Ron

I'm completely lost here, Ron.

Are you asking me to explain your requirements specs to you?

I have no idea even what a Site is; how a course is related to a site, etc.

You say IT is no help (well, that's not unusual :-{( ), but you have not -
that I have seen anyway - posted a human-readable description of the problem
that you are trying to solve. Let's step back a bit - what will people out in
the real world actually DO with this database?
 
R

Ron2006

John,

It is called "finger forgetfullness" (AND not re-reading my post
thoroughly before saying "Send")

I was trying to say that the subform (IT that I typed as I) did not
know what course ID to give to the site since the subform was being
opened independently and therefore did NOT have the actual associated
ID to load.


And the comments are all directed to LWG.


Ron. Sorry for the confusion
 
L

-LWG-

School (Main Form) record source = School

Courses (Sub Form 1) record source = Courses. Master/Child = School ID.

Sites (Sub Form 2) record source = Sites. Master/Child = Course ID.

The database needs to do this:

1 School has many Courses. Each course has many sites. From the Course
subform (to Schools) I want an action button that filters the sites for the
selected course...

Thanks...
 
R

Ron2006

On the MainForm that is bound to school, place and UNBOUND Txtbox
named txtThisCourseID - make visible property False.

In the Oncurrent event of the Course subform have it move the Course
ID to the field you just created.
Forms![MainForm]![txtThisCourseID] = me.CourseIDname.

In the FORM Property window in the Form Tab use the wizard to
establish the master/Child relationship between this subform and the
"MainFomr" txtThisCourseID.

This will automatically filter all sites for this course for this
school, and will automatically load the courseID into the site record
you create there.

Ron
 

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