-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You should use the BeforeUpdate event procedure on the subform to get
the values you want from the main form. This way, those values will
only be entered into the subform record when you've entered data in
the subform record & are about to save the record (by moving to
another record in the main form or subform, or closing the main form).
Example of subform's BeforeUpdate event:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.Parent!YearLevel) Then
Me!YearLevel = Me.Parent!YearLevel
End If
If Not IsNull(Me.Parent!SchoolDate) Then
Me!SchoolYear = Year(Me.Parent!SchoolDate)
End If
End Sub
Use Year() instead of DatePart() for the Year - easier.
Suggestions on table design:
1. It is not usually acceptable to have redundant data in 2, or more,
tables - the YearLevel is in both the main table (main form) and its
dependent table (subform).
2. The same for SchoolYear (a name I invented 'cuz you didn't give
the name of the column/field) - if the data is already in the main
(Parent) table the dependent record (subform record) doesn't need it.
You may have reasons for putting those data items in the dependent
table. If they are really good reasons ignore my pendantry.
HTH,
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBP/d/3oechKqOuFEgEQIihACfZqgXeApDKe7bCcyF4NvuPPbCiDUAoL 1F
SJ4wJmFAp+ZTPJ6Q742XcLlW
=0zrJ
-----END PGP SIGNATURE-----
Ray wrote:
I have a subform which takes one of its fields from the main form,
namely the YearLevel which is from 1 to 8. There is also another field
which returns the year from datePart.
If I select a record from the mainform is automatically creates a
record in the subform table even though I have not enter in the school
marks. This obviously comes from the YearLevel and the defaulted year.
is there a way of preventing this occurring. I only want a record in
the subform once I begin to enter the school marks. Maybe this is
impossible. Perhaps a delete query might help if all the score marks
are still null on closure?
Any ideas anyone? TIA - Ray