PC Review


Reply
Thread Tools Rate Thread

Autopopulate table field based on selection in previous field

 
 
Michael_Randall
Guest
Posts: n/a
 
      15th Aug 2009
I am trying to autopopulate a field in a table based on a selection in the
previous field. Here are my tables:

CLASS(ClassID(PK),CourseNumber(FK),InstructorID(FK))
COURSES(CourseNumber(PK), CourseName)
INSTRUCTORS(InstructorID, FName, LName)
INSTRUCTORCOURSES(InstructorID,CourseNumber) - junction table with composite
PKs

I've already filled out the INSTRUCTOR, COURSE, and INSTRUCTORCOURSES tables
and their relationships/ref integrity are already set up in Access. What I
would like to do is, in the CLASS table select a CourseNumber and based on
that CourseNumber, the InstructorID field is populated with a drop-down list.

Currently, I'm not using a Lookup for the CourseNumber in the table CLASS.
I'm considering basing that field (row source) on a query or the COURSE
table. I'm open to other solutions.


First, is this possible? Second, is this good database design? Third, how do
you do it, if you can?




--
Michael Randall
Technical Writer
Trend Micro, Nanjing China
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      15th Aug 2009
Michael,

Yes, this can be done.

You should be using a form for your data entry.

You can use a query as the Row Source of the InstructorID combobox. The SQL
view of such a query will look something like this...
SELECT InstructorCourses.InstructorID, [LName] & ", " & [FName] AS
InstructorName
FROM InstructorCourses INNER JOIN Instructors ON
InstructorCourses.InstructorID = Instructors.InstructorID
WHERE InstructorCourses.CourseNumber = [Forms]![NameOfForm]![CourseNumber]

If you also have a combobox for the CourseNumber, then you will probably
need to use macro or VBA code to Requery the InstructorID combobox on the
After Update event of the CourseNumber control.

--
Steve Schapel, Microsoft Access MVP


"Michael_Randall" <(E-Mail Removed)> wrote in
message news:F7BF63CE-382F-4650-8F9C-(E-Mail Removed)...
> I am trying to autopopulate a field in a table based on a selection in the
> previous field. Here are my tables:
>
> CLASS(ClassID(PK),CourseNumber(FK),InstructorID(FK))
> COURSES(CourseNumber(PK), CourseName)
> INSTRUCTORS(InstructorID, FName, LName)
> INSTRUCTORCOURSES(InstructorID,CourseNumber) - junction table with
> composite
> PKs
>
> I've already filled out the INSTRUCTOR, COURSE, and INSTRUCTORCOURSES
> tables
> and their relationships/ref integrity are already set up in Access. What I
> would like to do is, in the CLASS table select a CourseNumber and based on
> that CourseNumber, the InstructorID field is populated with a drop-down
> list.
>
> Currently, I'm not using a Lookup for the CourseNumber in the table CLASS.
> I'm considering basing that field (row source) on a query or the COURSE
> table. I'm open to other solutions.
>
>
> First, is this possible? Second, is this good database design? Third, how
> do
> you do it, if you can?
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
autopopulate fields in userform based on selection in one field sam Microsoft Excel Programming 0 14th Sep 2009 04:20 PM
Autopopulate fields based on selection from previous field Michael_Randall Microsoft Access 1 15th Aug 2009 10:28 AM
autopopulate field in a table based on value entered =?Utf-8?B?bW9uaWExMw==?= Microsoft Access 3 23rd Jan 2006 07:31 PM
Locking a field based on a previous selection BRIAN PASTRE Microsoft Outlook Form Programming 0 19th Jun 2005 10:49 PM
Filling in value of field from other table based on previous field entry =?Utf-8?B?U3BpZmZ1cw==?= Microsoft Access Macros 1 4th Jun 2004 08:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.