Transcript of the Video:- Adding Hobbies to a Student Database
Create 3 tables, tblHobby tblStudent tblStudentHobby. The construction of them will be like this, so from that information you should be able to reconstruct those tables.
Now highlight tblSudent press create, create a form, close it. Give it a name frmStudent now do the same with frmStudentHobby, create form but this time you want to edit the form and select the properties, call up the property sheet, change the default view to datasheet. Close the form and we will make that a subform, it’s no different than a main form. Now open the student form in design view, make yourself a bit of room and then drag this one, the Hobby form in here like this, I’m just adjusting some sizes, save changes.
Now open the students form again and we’ve got the student form and the student hobby form on the same form. I’m going down the bottom of the screen, have a look see if I can show you, now I’m going to flick through these, like this. I will move back up and show you what is happening while I’m doing that. So I’ve gone down the bottom of the screen and I’m flicking through those. Can you see how the student ID are synchronised? So that means if we go back to student 1 if I add hobby 1 I’m going to move on to student 2 and I’m going to add hobby 1 and Hobby 2 then I’m going to move on to students 3 and add hobby 1, 2 and 3 Now if I go back to the beginning as you can see the data matches, we’ve got hobby 1, if I move on to student 2, we’ve got hobbies 1 and 2 and student 3 we’ve got hobbies 1, 2 and 3.
Problem is we’re not seeing hobby here, so we need to go into the student hobby form and make a small change. Design view, we want we got student ID showing, we just want to change this to a combo-box, when you change to a combobox rename it, so I’m going into the properties, other, name it, “cbo” and we’re going to change its row source slightly so we open up the…
I’ve gone down the bottom of the list and selected properties and then we go here and in here we select hobby table, so now it will display records from the Hobby table. We want it to “limit to list” because we don’t want people to add other hobbies to the list, not without our permission, and format, we want to see two columns, so change that to 2, but we don’t want to see two columns, so the column widths we show the first one we will show 0 so we can’t see it, and the second one we will show 2 and MS Access will sort that out for us changing that to centimetres.
We don’t want column heads, there’s lots of things we can do there but you can experiment with that yourself save changes now let’s open up a form students. Now, do you remember we had one showing there before and for the next record we had 1 and 2 showing and now we’ve got hobby 1 and hobby 2 so if you look in the Hobby table we use to have “1” showing now we’ve got Hobby 2 showing ok! So that’s about it really, you can add your hobbies to your heart’s content in the list.