A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SUBFORM - AUTO POPULATE PRIMARY KEY



 
 
Thread Tools Display Modes
  #1  
Old March 6th, 2008, 07:52 PM posted to microsoft.public.access.forms
-LWG-
external usenet poster
 
Posts: 1
Default SUBFORM - AUTO POPULATE PRIMARY KEY

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...


  #2  
Old March 7th, 2008, 04:17 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default SUBFORM - AUTO POPULATE PRIMARY KEY

On Thu, 6 Mar 2008 10:52:00 -0800, -LWG-
wrote:

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?
--
John W. Vinson [MVP]
  #3  
Old March 7th, 2008, 04:14 PM posted to microsoft.public.access.forms
Ron2006
external usenet poster
 
Posts: 936
Default SUBFORM - AUTO POPULATE PRIMARY KEY

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
  #4  
Old March 7th, 2008, 04:36 PM posted to microsoft.public.access.forms
Ron2006
external usenet poster
 
Posts: 936
Default SUBFORM - AUTO POPULATE PRIMARY KEY

IT has no idea......
  #5  
Old March 7th, 2008, 06:07 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default SUBFORM - AUTO POPULATE PRIMARY KEY

On Fri, 7 Mar 2008 07:14:25 -0800 (PST), Ron2006 wrote:

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?
--
John W. Vinson [MVP]
  #6  
Old March 7th, 2008, 06:32 PM posted to microsoft.public.access.forms
Ron2006
external usenet poster
 
Posts: 936
Default SUBFORM - AUTO POPULATE PRIMARY KEY

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
  #7  
Old March 10th, 2008, 07:48 PM posted to microsoft.public.access.forms
-LWG-[_2_]
external usenet poster
 
Posts: 1
Default SUBFORM - AUTO POPULATE PRIMARY KEY

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...

"John W. Vinson" wrote:

On Thu, 6 Mar 2008 10:52:00 -0800, -LWG-
wrote:

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?
--
John W. Vinson [MVP]

  #8  
Old March 10th, 2008, 08:59 PM posted to microsoft.public.access.forms
Ron2006
external usenet poster
 
Posts: 936
Default SUBFORM - AUTO POPULATE PRIMARY KEY

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
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.