L
Lloyd
I have a tabbed form, when I switch from one tab to another, it checks to
make sure that none of the mandatory fields are missing. However the code
that checks the records on tab #1 (which is the code below after the elseif),
the code only checks the first record. I can not figure out how to modify
the code to get it to look at other records on the form that may be present.
Any suggestions on what modification I would need to make here would be
helpful.
thanks!
If TabCtl4 = 1 Then
Dim CkCtls As New Collection
CkCtls.Add "DRNo"
CkCtls.Add "DateOccd"
CkCtls.Add "TimeOccd"
CkCtls.Add "CaseType"
CkCtls.Add "Dispo"
CkCtls.Add "Location"
CkCtls.Add "City"
CkCtls.Add "Division"
'CkCtls.Add "Detective1"
CkCtls.Add "ShootingType"
Dim var As Variant
For Each var In CkCtls
If IsNull(Me(var)) Then
'Me(var).BackColor = 11468799 ' light yellow
MsgBox var & " Field MUST be completed", vbCritical +
vboko, "You left fields empty"
Me(var).BackColor = 255 ' Red
Me!TabCtl4.Value = 0
Else
'MsgBox "no fields are null"
'Me(var).BackColor = 16777215 ' white
End If
Next
ElseIf TabCtl4 = 4 Then
'TAB #1 continuous form - NEED TO CYCLE THROUGH ALL RECORDS ON FORM
Dim CkCtls1 As New Collection
CkCtls1.Add "LastName"
CkCtls1.Add "PersonType"
CkCtls1.Add "PersonCaseType"
Dim var1 As Variant
For Each var1 In CkCtls1
If IsNull([Forms]![frmMainEntry]![subfrmPersons](var1)) Then
'Me(var).BackColor = 11468799 ' light yellow
MsgBox var1 & " Field MUST be completed", vbCritical +
vboko, "You left fields empty"
[Forms]![frmMainEntry]![subfrmPersons](var1).BackColor =
255 ' Red
Me!TabCtl4.Value = 1
Else
'MsgBox "no fields are null"
'Me(var).BackColor = 16777215 ' white
End If
Next
Else
End If
make sure that none of the mandatory fields are missing. However the code
that checks the records on tab #1 (which is the code below after the elseif),
the code only checks the first record. I can not figure out how to modify
the code to get it to look at other records on the form that may be present.
Any suggestions on what modification I would need to make here would be
helpful.
thanks!
If TabCtl4 = 1 Then
Dim CkCtls As New Collection
CkCtls.Add "DRNo"
CkCtls.Add "DateOccd"
CkCtls.Add "TimeOccd"
CkCtls.Add "CaseType"
CkCtls.Add "Dispo"
CkCtls.Add "Location"
CkCtls.Add "City"
CkCtls.Add "Division"
'CkCtls.Add "Detective1"
CkCtls.Add "ShootingType"
Dim var As Variant
For Each var In CkCtls
If IsNull(Me(var)) Then
'Me(var).BackColor = 11468799 ' light yellow
MsgBox var & " Field MUST be completed", vbCritical +
vboko, "You left fields empty"
Me(var).BackColor = 255 ' Red
Me!TabCtl4.Value = 0
Else
'MsgBox "no fields are null"
'Me(var).BackColor = 16777215 ' white
End If
Next
ElseIf TabCtl4 = 4 Then
'TAB #1 continuous form - NEED TO CYCLE THROUGH ALL RECORDS ON FORM
Dim CkCtls1 As New Collection
CkCtls1.Add "LastName"
CkCtls1.Add "PersonType"
CkCtls1.Add "PersonCaseType"
Dim var1 As Variant
For Each var1 In CkCtls1
If IsNull([Forms]![frmMainEntry]![subfrmPersons](var1)) Then
'Me(var).BackColor = 11468799 ' light yellow
MsgBox var1 & " Field MUST be completed", vbCritical +
vboko, "You left fields empty"
[Forms]![frmMainEntry]![subfrmPersons](var1).BackColor =
255 ' Red
Me!TabCtl4.Value = 1
Else
'MsgBox "no fields are null"
'Me(var).BackColor = 16777215 ' white
End If
Next
Else
End If