L
Lorien2733
Hi,
I have a form that shows info for students that have applied to magnet
schools in the district. The form has student info (name,address etc) and a
subform that displays one record for each of the schools they have applied
to, linked by a student ID. They can apply, register and be accepted to
multiple schools but they can only be admitted to one. To further complicate
matters, there may be records from more than one school year.
I thought I could use Dlookups. Something like
Private Sub Enrolled_BeforeUpdate(Cancel As Integer)
Dim Var1, Var2, Var3 As String
Var1 = DLookup([Enrolled], "tblSchoolDetail", "[tblSchoolDetail].[StudentID]
= me![StudentID]")
Var2 = DLookup([SchoolAppliedTo], "tblSchoolDetail",
"[tblSchoolDetail].[StudentID] = me![StudentID]")
Var3 = DLookup([SchoolYear], "tblSchoolDetail",
"[tblSchoolDetail].[StudentID] = me![StudentID]")
If (Var1 = -1) And (Not Var2 = Me![SchoolAppliedTo]) And (Not Var3 =
Me![SchoolYear]) Then
If MsgBox("This student has already been accepted by " & "var2", vbQuestion
+ vbYesNo, "Duplicate Admission") = vbNo Then
Cancel = True
End If
End If
This of course doesn't work and I'm totally confused. Any suggestions?
Thank you for not laughing at my code.
I have a form that shows info for students that have applied to magnet
schools in the district. The form has student info (name,address etc) and a
subform that displays one record for each of the schools they have applied
to, linked by a student ID. They can apply, register and be accepted to
multiple schools but they can only be admitted to one. To further complicate
matters, there may be records from more than one school year.
I thought I could use Dlookups. Something like
Private Sub Enrolled_BeforeUpdate(Cancel As Integer)
Dim Var1, Var2, Var3 As String
Var1 = DLookup([Enrolled], "tblSchoolDetail", "[tblSchoolDetail].[StudentID]
= me![StudentID]")
Var2 = DLookup([SchoolAppliedTo], "tblSchoolDetail",
"[tblSchoolDetail].[StudentID] = me![StudentID]")
Var3 = DLookup([SchoolYear], "tblSchoolDetail",
"[tblSchoolDetail].[StudentID] = me![StudentID]")
If (Var1 = -1) And (Not Var2 = Me![SchoolAppliedTo]) And (Not Var3 =
Me![SchoolYear]) Then
If MsgBox("This student has already been accepted by " & "var2", vbQuestion
+ vbYesNo, "Duplicate Admission") = vbNo Then
Cancel = True
End If
End If
This of course doesn't work and I'm totally confused. Any suggestions?
Thank you for not laughing at my code.