I have two tables, one is called Sample and the other Results. With a relationship of one to many. (One sample can have many results)
What I am trying to do is select a date and display the results of the test for the next 14 days. (Eg Say a user selects 10/10/2002 then the next 14 days will be shown with the results.)
Anyway I have written the following code to find the date from the tables selected, if the results have been gather for that date and then get the next day. If no results are found for that date then ignore the date and move on to the next date.
Public Sub CollectdateSampleValues(ByVal txtDateRcvd As Date)
Dim I As Integer
Dim rsTmp, rsDateAndListerine As DAO.Recordset
Dim strSQL As String
Dim CountOfOccurances As Integer
Dim CountOfICert As Integer
strSQL = "SELECT COUNT(*) AS FOUND FROM " & " Results RIGHT JOIN Sample ON Results.ISmpN = Sample.ISmpN " & _
"WHERE (((Sample.ISmpDateRcvd)= " & txtDateRcvd & ") AND ((Results.ICertCertifDesc) Like ""listeria* "")); "
Set rsTmp = CurrentDb.OpenRecordset(strSQL)
If rsTmp.Fields(0).Value > 0 Then
rsTmp.Close
End If
End Sub
When I ran the program and reach the “if “statement it shows no records have been found although I know for a fact that the date selected has 48 results. So the “if” statement should me greater then 0 and carry, not exit. Can someone help please.
What I am trying to do is select a date and display the results of the test for the next 14 days. (Eg Say a user selects 10/10/2002 then the next 14 days will be shown with the results.)
Anyway I have written the following code to find the date from the tables selected, if the results have been gather for that date and then get the next day. If no results are found for that date then ignore the date and move on to the next date.
Public Sub CollectdateSampleValues(ByVal txtDateRcvd As Date)
Dim I As Integer
Dim rsTmp, rsDateAndListerine As DAO.Recordset
Dim strSQL As String
Dim CountOfOccurances As Integer
Dim CountOfICert As Integer
strSQL = "SELECT COUNT(*) AS FOUND FROM " & " Results RIGHT JOIN Sample ON Results.ISmpN = Sample.ISmpN " & _
"WHERE (((Sample.ISmpDateRcvd)= " & txtDateRcvd & ") AND ((Results.ICertCertifDesc) Like ""listeria* "")); "
Set rsTmp = CurrentDb.OpenRecordset(strSQL)
If rsTmp.Fields(0).Value > 0 Then
rsTmp.Close
End If
End Sub
When I ran the program and reach the “if “statement it shows no records have been found although I know for a fact that the date selected has 48 results. So the “if” statement should me greater then 0 and carry, not exit. Can someone help please.