your cake detail table should have a field (StudendID Long). so we know to student this cake is for.
if you already have done that, add the new field in your datasheet view (must).
if you dont want to show it, use the subforms open event:
private sub form_open(cancel as integer)
me.StudentID.ColumnHidden = True
end sub
back to design view.
click on the cake detail subform.
on the property sheet->data:
Link Master Fields: ID
Link Child Fields: StudentID
select your main form (click on the square).
add this on the main form's current event:
Private Sub Form_Current()
Dim rs As DAO.recordSet
If Not Me.NewRecord Then
Set rs = Me.tblCakeSubform.Form.RecordsetClone
With rs
If .RecordCount = 0 Then
.AddNew
![StudentID] = Me.ID
![Cake] = "Chocolate Cake"
.Update
.AddNew
![StudentID] = Me.ID
![Cake] = "Strawberry Cake"
.Update
.AddNew
![StudentID] = Me.ID
![Cake] = "Toffe Cake"
.Update
End If
.Close
End With
End If
End Sub