I have a beforeinsert event on a sub form and am trying to do some validation on it. Basically when a user clicks a value on a combo box within the sub form it hits the code below in the beforeinsert event. However, "Meet" (combo box value) is null when I clicked on No. What am I doing wrong?????
Dim stincid As Long
Dim lngTotal As Long
Dim lngno As Long
Dim lngyes As Long
stincid = Nz(Forms!Adult_outcomes.Adult_Outcomes_SF!INC_ID, 0)
lngTotal = (DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid) + 1)
lngyes = DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid & "and [pln_meet] = 'Yes'")
lngno = DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid & "and [pln_meet] = 'No'")
If Meet = "No" And lngyes > 0 And lngTotal > 1 Then
Me.Undo
Cancel = True
MsgBox ("worked")
ElseIf Meet = "Yes" And lngno > 0 And lngTotal > 1 Then
Me.Undo
Cancel = True
MsgBox ("worked yes")
End If
Dim stincid As Long
Dim lngTotal As Long
Dim lngno As Long
Dim lngyes As Long
stincid = Nz(Forms!Adult_outcomes.Adult_Outcomes_SF!INC_ID, 0)
lngTotal = (DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid) + 1)
lngyes = DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid & "and [pln_meet] = 'Yes'")
lngno = DCount("[pln_inc_id]", "adult_plan", "[pln_inc_id] =" & stincid & "and [pln_meet] = 'No'")
If Meet = "No" And lngyes > 0 And lngTotal > 1 Then
Me.Undo
Cancel = True
MsgBox ("worked")
ElseIf Meet = "Yes" And lngno > 0 And lngTotal > 1 Then
Me.Undo
Cancel = True
MsgBox ("worked yes")
End If