Hi There
I am creating a questionaire to find out how a participant will grade particular subjects.
I have a list of 20 subjects in a table called Subjects.
I have created a form in which the participant enters their details and these are stored in a Customer table.
I then want to populate a table Customer_Subjects with fields Customer and Subject so that there is a record in the new table for the customer and every subject. ie
John Physics
John Maths
John English
How would I do this?
Also, ideally I would like to be able to do this automatically when the save record button is pressed on my original new customer form. What is the best way for this?
Many Thanks
9 1878
Welcome to Bytes, Terence
Your question is rather vague. You have the information before you, we can only guess what you want
See https://bytes.com/faq.php?faq=how_to...fic_guidelines
Anyway, I'm going to assume that you have done things correctly and have 2 tables -
TblCustomers
-
CustomerID AutoNumber Primary Key
-
CustomerFirstName Text
-
CistomerLastName Text
-
....
-
....
and - TblSubjects
-
SubjectID AutoNumber Primary Key
-
Subject Text Required - Yes, Allow Zero Length - No
-
Indexed - Yes(No Duplicates)
Then you need a new table to join the 2 tables above -
TblJoinCustomerSubject
-
CustomerID Number Long Joint Primary Key
-
SubjectID Number Long Joint Primary Key
-
Grade Number
-
Set up and enforce relationships between the 3 tables.
Your main for will be for customers and you will have a continuous Subform with Combo Boxes for the various subjects
Here is a botched picture to give you the idea.
The beauty of this method is that although you normally would have the Customer as the main form, and see the subjects he studies on the subform, you can do it the other way round, and have the Subject as the main form and see which customers are studying that subject.
Phil
Thanks Phil... appologies for the vagueness. Will try to improve that next time.
Yes I had setup the table correctly. The outcome I am trying to get is a little different from what you suggested though.
To use your example, say I have the following table
TblSubjects
SubjectID Subject
1 Maths
2 Physics
3 Biology
4 English
If then I create a new customer record in the following table
TblCustomers
CustomerID CustomerFirstName CustomerLastName
1 John Smith
How can I then autopopulate TblJoinCustomerSubject with records so that the new customer has a record for each subject (see below)?
CustomerID SubjectID
1 1
1 2
1 3
1 4
Terence
The tables are fine, and the Join table will give you exactly what you have, but you also said you needed a column of Grades as well, and you may also need a column to show the Date the Grade was awarded. They also go into the Join table as mentioned in an earlier post.
In regards to the "Populate" your table automatically.
Now here are some question that need careful thought before answering.
1) Will EVERY Customer ALWAYS be involved with ALL 20 subjects?
2) What happens when you add Subject 21? (I ask this because a database should be designed to be "future proof" - e.g. additional or change of subjects.
3) If the answer to question 1 is "Yes" (and I would be a little surprised if it were), is your intention to add the 20 Subjects automatically as you enter a new Customer?
What you are asking for is comparatively simple to achieve, but you will need to use a bit of VBA code. Are you happy with this?
Phil
Hi Phil
In regard to your questions:
1. Yes
2. If subject 21 is added, existing customers will still have 20 subjects, however future customers will have 21 subjects populated for them.
3. Yes... All subjects to be automatically populated when adding a new customer.
VBA will be fine. I will learn as I go.
Thanks.
Hi Terence
OK, I suggest you have a go at creating your Customer Main form and a continuous Subject Subform. Remember, with the Subform, the RecordSource should include all the fields from your Join table + Subject from your TblSubjects. Also it needs setting to Allow Edits - No, Allow Additions - No and Allow Deletions - No.
If you would like me to look at this before dealing with the automatic population of the Join table, let me know.
Phil
Okay. Thanks will make sure that It is set up the way you suggest. No need for me to run it by you at the moment.
Would love if you can let me know how to automatically populate using VBA though.
"First thing first"?
I appreciatte your help Phil but I am not wanting you to look at the tables and form set up. My tables and forms are different to those described here. I have used your example tables for simplicity.
If you answer the question according to the setup you described, I can then adjust it to my setup.
Will you do this or not?
zmbd 5,501
Expert Mod 4TB
(...) To use your example, say I have the following table
TblSubjects
SubjectID Subject
If then I create a new customer record in the following table
TblCustomers
CustomerID CustomerFirstName CustomerLastName
1 John Smith
How can I then autopopulate TblJoinCustomerSubject with records so that the new customer has a record for each subject (see below)?
CustomerID SubjectID
1 1
(...)
Not sure where Phil is going with this at this point; however, I'm sure that he's waiting for you to let us know that your forms are properly setup.
While we're waiting, I would think that a simple update/append query should achieve this action.
Start with a simple select query - this is based on a student database I use - you should be able to get the idea.
For a single student we would start with something like" - SELECT StudentList.PK_StudentList
-
, t_Assignment.PK_Assignment
-
FROM StudentList, t_Assignment
-
WHERE (((StudentList.PK_StudentList)=1));
This should give you the Cartesian product between the two tables filtered down to one student.
Make sure the query looks right (one record entry for each combination of the student and subject) then one would switch to the action query - here I'll use t_ActiveAssignments: - INSERT INTO t_ActiveAssignments
-
( FK_StudentList, FK_Assignment )
-
SELECT StudentList.PK_StudentList
-
, t_Assignment.PK_Assignment
-
FROM StudentList, t_Assignment
-
WHERE (((StudentList.PK_StudentList)=1));
You can use this as a stored query and have the VBA code set a member of the TempVars Object (Access) collection for the criteria: - INSERT INTO t_ActiveAssignments
-
( FK_StudentList, FK_Assignment )
-
SELECT StudentList.PK_StudentList
-
, t_Assignment.PK_Assignment
-
FROM StudentList, t_Assignment
-
WHERE (((StudentList.PK_StudentList)
-
=TempVars![StudentID]));
This way one doesn't have to open a recordset etc...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ward B |
last post by:
Greetings.
I'm somewhat new to this whole MySQL/PHP thing and need a little help.
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text...
|
by: Svelte Poshy |
last post by:
Populating a field in a table depending on another
In my table customers i want to populate the field segmenid depending on
the
choice in the lookup field Typeid. Both fields, typeid and...
|
by: shobhit_shanker |
last post by:
Here are the relevant "givens" to my problem...
Form: frmLaunchRpt
- Text Box: txtAsOfDate
- Check Box: chkLogEval
- Command Button: cmdLaunchRpt
Report: rptEvaluation
- Text Box:...
|
by: dino07 |
last post by:
Hi All,
I am currently trying to do the following:
1. insert a value into a repeating table from a drop-down list( secondary
storage) when the user click the "Add" button positioned next to the...
|
by: gg77 |
last post by:
Hi,
I don't have much knowledge of the table control. I am basically trying to
use a table thats populated with data rows from a dataSet but currently
things aren't working for me.
below is...
|
by: keliie |
last post by:
I have a relatively simple (I assume) issue which I am at a complete
loss to address. My issues is: I want to populate fields in my tables
with summary data from the same table. Let me explain:
...
|
by: Richard Rosser |
last post by:
Greetings.
Can somebody please point me in the direction of
good reference material with a 'how-to' on building
a web form that will post selected data from the form
to an Access (2002) as well...
|
by: anfetienne |
last post by:
hi this question is linked to this post ive made in the mysql section.
http://bytes.com/topic/mysql/answers/871536-populating-table#post3499253
simply i want to use a form to populate a table...
|
by: calbaptedm |
last post by:
Have a table with my master information for individuals and would like to automatically export the data to other tables based on the criteria selected. On my master table you can select multiple...
|
by: lgoddgreat |
last post by:
Hi I have this project, and I've been working on it for days. I decided to add something like a tracking record on my project, the users Login and Logout time will be tracked and stored on the ...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |