I am trying to count the occurrences of the LEFT 6 characters on my form field.
This code throws a "Compile Error: Type mismatch" on intDailyCount =rs I cant seem to figure it out
This code throws a "Compile Error: Type mismatch" on intDailyCount =rs I cant seem to figure it out
Code:
Private Sub Command79_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intDailyCount As Integer
Dim sqlRoot As String
Set db = CurrentDb
sqlRoot = "SELECT tbl_SampleGroups.GroupNumber, Count(tbl_Samples.GroupID) AS CountOfGroupID " & _
"FROM tbl_Samples INNER JOIN tbl_SampleGroups ON tbl_Samples.GroupID = tbl_SampleGroups.SampleGroupID " & _
"GROUP BY tbl_SampleGroups.GroupNumber " & _
"HAVING (((tbl_SampleGroups.GroupNumber)=Left([Forms]![frm_Login]![GroupNumber],6)));"
Set rs = db.OpenRecordset("sqlRoot")
intDailyCount = rs
Me.txtSampleCount = intDailyCount
Set rs = Nothing
End Sub