J
Jeff
Hi,
The following is part of my program used to count the result of hearing test
on baby and it works. If the baby passes the first time on both ears, we
issue a pass. If the baby fails the first time, either on one ear or both
ears, we perform a second time. If pass on both ears, we issue a pass. If
fail either on one ear or both ears, we issue a fail.
I can display the result with MsgBox, but I want to display the results on a
"Form" like a table as follow:
Year/Month of Test Total number done No. Pass No. Fail Pass rate
Fail rate
How can I do that? Should I store the results in a "temporary table" first
then get the data from the temporary table to display them on a "Form"? Thank
you.
Private Sub btnCount_Click()
Dim strMinDate As String
Dim strMaxDate As String
Dim dMinDate As Date
Dim dMaxDate As Date
Dim dScreenMonth As Date
Dim intMonthCount As Integer
Dim lngPass1 As Long
Dim lngPass2 As Long
Dim lngPass As Long
Dim lngFail2 As Long
strMinDate = DMin("[ScreenDate1]", "tbResult") 'I use String type for
ScreenDate1
strMaxDate = DMax("[ScreenDate1]", "tbResult")
dMinDate = TxtDate(strMinDate) 'I have a function to convert String type
ScreenDate1 to Date type
dMaxDate = TxtDate(strMaxDate)
dScreenMonth = dMinDate
intMonthCount = DateDiff("m", dMinDate, dMaxDate) + 1
Dim i As Integer
Dim strPass As String
Dim strFail As String
'pass=1, fail=2
For i = 1 To intMonthCount
lngPass1 = DCount("[MasterID]", "tbResult", "[RResult1] = 1 And
[LResult1] = 1 And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) &
"'")
lngPass2 = DCount("[MasterID]", "tbResult", "[RResult2] = 1 And
[LResult2] = 1 And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) &
"'")
lngPass = lngPass1 + lngPass2
lngFail2 = DCount("[MasterID]", "tbResult", "[RResult2] = 2 And
Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) & "' Or [LResult2] = 2
And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) & "'")
strPass = strPass & lngPass & " "
strFail = strFail & lngFail2 & " "
dScreenMonth = DateAdd("m", 1, dScreenMonth)
Next
MsgBox strPass & strFail
End Sub
The following is part of my program used to count the result of hearing test
on baby and it works. If the baby passes the first time on both ears, we
issue a pass. If the baby fails the first time, either on one ear or both
ears, we perform a second time. If pass on both ears, we issue a pass. If
fail either on one ear or both ears, we issue a fail.
I can display the result with MsgBox, but I want to display the results on a
"Form" like a table as follow:
Year/Month of Test Total number done No. Pass No. Fail Pass rate
Fail rate
How can I do that? Should I store the results in a "temporary table" first
then get the data from the temporary table to display them on a "Form"? Thank
you.
Private Sub btnCount_Click()
Dim strMinDate As String
Dim strMaxDate As String
Dim dMinDate As Date
Dim dMaxDate As Date
Dim dScreenMonth As Date
Dim intMonthCount As Integer
Dim lngPass1 As Long
Dim lngPass2 As Long
Dim lngPass As Long
Dim lngFail2 As Long
strMinDate = DMin("[ScreenDate1]", "tbResult") 'I use String type for
ScreenDate1
strMaxDate = DMax("[ScreenDate1]", "tbResult")
dMinDate = TxtDate(strMinDate) 'I have a function to convert String type
ScreenDate1 to Date type
dMaxDate = TxtDate(strMaxDate)
dScreenMonth = dMinDate
intMonthCount = DateDiff("m", dMinDate, dMaxDate) + 1
Dim i As Integer
Dim strPass As String
Dim strFail As String
'pass=1, fail=2
For i = 1 To intMonthCount
lngPass1 = DCount("[MasterID]", "tbResult", "[RResult1] = 1 And
[LResult1] = 1 And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) &
"'")
lngPass2 = DCount("[MasterID]", "tbResult", "[RResult2] = 1 And
[LResult2] = 1 And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) &
"'")
lngPass = lngPass1 + lngPass2
lngFail2 = DCount("[MasterID]", "tbResult", "[RResult2] = 2 And
Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) & "' Or [LResult2] = 2
And Month(TxtDate(ScreenDate1)) ='" & Month(dScreenMonth) & "'")
strPass = strPass & lngPass & " "
strFail = strFail & lngFail2 & " "
dScreenMonth = DateAdd("m", 1, dScreenMonth)
Next
MsgBox strPass & strFail
End Sub