entering data into subform

trish

really crap at access
Local time
Today, 21:30
Joined
Apr 24, 2001
Messages
19
hi

i've got a subform that i can't enter information into.

i have an enrolment subform in a student main form. the subform is a repeating group which is supposed to show unit enrolment and also allows me to add new unit enrolments. however it only seems to show information that has been directly entered into the table and not from the form.

when i try and enter new enrolments into the subform, it shows up with "you cannot add or change a record because a related record is required in table 'Student'".

i've checked my relationships and the one-to-many relationship is correct (i think) with the PK StudentID in the student table, linked to the FK StudentID in the enrolment table.

I've also tried setting the Data Entry criteria in the properties sheet to "yes" however although it allows me to enter new enrolments, it doesn't show the other unit enrolments that were previously entered.

thanks
trish
 
is that the same as the links in the relationship diagram? if not then probably not. how would i do that?
 
You're on the right track, but it's not the same thing. When you create a form with a subform on it, Access needs to know how to relate the two. The subform is usually related to the main form by a field or two. So when you move between records on the main form, you see related records in the subform.

It's been a while for me, but if you've set the relationships properly in the relationship window, and you place a subform into a main form where they have fields that you've previously defined joins between, then Access will attempt to set the "Link Child Fields" and "Link Master Fields" for you.

If you look at a form with a subform in form design view, click on the subform and you look at the properties sheet. Click on the Data tab and you'll see the two "Link" fields I mentioned in the last paragraph. So, for example, if for each StudentID in the main form, you want to see enrollment detail in the subform, the "Link" fields should both show "StudentID". If not, put them there.
 
The reason that you're getting that error message is because the value that you have for StudentID (FK) in your subform doesn't exist in the main table Student. Are you sure you're entering the Student ID in the main form before you try to add data to the subform?

Also, the Data Entry = Yes property means that users will only be allowed to enter new records, not to view or edit existing records.
 
dcx693 - i've added 'StudentID' into the property sheet in both the link child and master fields for the Enrolment subform, but now i get a message (when i tried to enter data into the form view)
"The object doesn't contain the Automation object 'StudentID'.

You tried to run a Visual Basic procedure to set a property or method available for Automation operations.

Check the component's documentation for information on the properties and methods it makes available for Automation operations."

Idjit - when i created the subform i didn't insert the 'StudentID' field into it as i assumed that it would pick it up considering that the Student table and Enrolment table are linked through the 'StudentID' on the main table, is that where i might be going wrong?

the process that i began with was to enter 1 student's details into the student table and then through the relationship cascaded the enrolment table and enter the enrolment information. then i created the forms and tried to enter data that way, but hence the trouble i'm having, because it will show up cascaded in the tables but not in the forms.
 
trish,

Yes, make sure that StudentID is on both the main and the subform. If you don't need to see it on the subform, you can set the field's Visible property to "No". That should take care of both your original problem and the new error message you're getting (I think the reason for that is that you refer to StudentID in the Link Child/Master properties, but it doesn't exist on the form).

Let us know if you still have trouble.

:)
 
StudentID only has to be in the underlying recordset, it doesn't need to be on the subform, post a 97ver copy of your db and someone will take a look at it for you
 
i've added the StudentID field into the subforms with it set at visible = no, and it's worked. which is great Idjit, thanks.

but i've also attached the db for more help, as per Rich's comments. i hope i converted it ok.
 

Attachments

subform entry problem

Hi

I have the same problem as Trish but can't seem to rectify mine from the notes.

Can anybody please help?

I have attached my file.

Thanks
 

Attachments

Users who are viewing this thread

Back
Top Bottom