简体   繁体   中英

How can I use a combo box that displays data from one table and add it to another using MS Access?

I am developing a database system. It is for a canoe club. The part of the database I am stuck on is assigning a member of the canoe club to a canoe qualification course when/if they undertake one.

Here is a stripped down view of my tables:

members
-------------------------------------
| memberID | first_name | last_name |
-------------------------------------
| 1        | John       | Jacobs    |
| 2        | Ellie      | Graham    |
| 3        | Paul       | Abbot     |
-------------------------------------

course_info
---------------------------------------
| courseID | course_name | Instructor |
---------------------------------------
| 1        | BCU Level 1 | Ryan Adams |
| 2        | BCU Level 2 | Ryan Adams |
| 3        | BCU Level 3 | Ryan Adams |
| 4        | BCU Level 4 | Ryan Adams |
| 5        | BCU Level 5 | Ryan Adams |
---------------------------------------

course_progress
-------------------------------
| memberID | courseID | grade |
-------------------------------
| 1        | 2        | 4     |
| 1        | 4        | 5     |
| 2        | 1        | 3     |
| 3        | 5        | 2     |
-------------------------------

So as you can see, course_progress displays the courses a member has undertaken as well as their grade by using memberID and courseID .

Firstly is that the correct (or a correct) way of doing this? If so, here is my problem...

Using Access I want to create a form that allows me to assign a member to a course. So I have a combo box that lists all of the members and another that lists all of the courses. As well as a box for inputting the grade.

When I fill in this form it only adds the grade to the course_progress table. I feel as though this is the case because I am using fields from different tables in the combo box. The other solution that while works is less than ideal is to have memberID and courseID in the combo box. I believe that works as I am using fields from the table I am trying to add to. However it is not user friendly as ID's are meaningless to a user.

So I want to be able to select the member name and course name from the combo box and add them to the course_progress table as well as the grade.

Any guidance would be great.

Thanks.

Firstly, is your form bound to the course_progress table., and are the two combo boxes bound to the memberID and courseID fields of the progress table.

Secondly, what have you used as the query for each combo box. You should be querying the members table. Assuming you do, you will have 3 columns, the first being the member ID and that should be the "bound column" in the combo box properties. in the format section you will need to give column widths, and I would give the memberID column a width of 0 so it doesn't show. But you should say you want to display 3 columns (so you get firstname and last name in the combo box.

Do the same for the course combo box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM