I mentioned it in a different thread, sorry. I guess I forgot to include that in this one.
Here's the code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim y As Integer 'each subscript in the array
Dim Specialties(30) As String 'types of specialties
Dim SpecCodes(30) As String 'code for each specialty
Dim tmpCount As Integer 'to count the number of records in a given condition
Dim tmpCode As String 'the current code for comparison
Dim rstReports As New ADODB.Recordset
Dim rstReports2 As New ADODB.Recordset
y = 0
tmpCount = 0
tmpCode = ""
rstReports.Open "SELECT SpecialtyCode,SpecialtyDesc FROM SpecialtyInfo", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
rstReports2.Open "SELECT * FROM PerMonInput", CurrentProject.Connection, adOpenDynamic, adLockReadOnly
rstReports.MoveFirst
rstReports2.MoveFirst
With rstReports
Do While Not .EOF
For y = 1 To 30
rstReports2.MoveFirst
SpecCodes

= ![SpecialtyCode]
Specialties

= ![SpecialtyDesc]
Do While Not rstReports2.EOF
tmpCode = rstReports2![Surgical_Specialty_ID]
If tmpCode = SpecCodes

And rstReports2![Cancelled_Cases] = "Yes" Then
tmpCount = tmpCount + 1
If Not rstReports2.EOF Then
rstReports2.MoveNext
Else
rstReports2.MoveLast
End If
Else
rstReports2.MoveNext
End If
Loop
Me.Text8 = Specialties

Me.Text10 = tmpCount
tmpCount = 0
.MoveNext
If .EOF = True Then
Exit Sub
End If
Next y
Loop
End With
End Sub
I'm not sure if that's even the best way to go about it. It works, though, except for overwriting the previous value. Any suggestions would be appreciated. Thanks.