cken21
Technical User
- Oct 19, 2011
- 37
Hi,
Can anybody help me with the following code, this is an excel userform acting as the front end of a database. What this tool does is searches the database and return the number of entries present where a specified condition is met, in this case it refers to escalated "Yes" or "No". I not receiving any run time error but the 3 fields to be filled always return a value of 0 which is not accurate. i have posted the code below.
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalFeedback = rs.RecordCount
tbCom.Value = totalFeedback
Set rs = Nothing
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Escalated] = '" & "Yes" & "' AND [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalEsc = rs.RecordCount
tbEsc.Value = totalEsc
Set rs = Nothing
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Escalated] = '" & "No" & "' AND [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalNonEsc = rs.RecordCount
tbNonEsc.Value = totalNonEsc
Set rs = Nothing
Can anybody help me with the following code, this is an excel userform acting as the front end of a database. What this tool does is searches the database and return the number of entries present where a specified condition is met, in this case it refers to escalated "Yes" or "No". I not receiving any run time error but the 3 fields to be filled always return a value of 0 which is not accurate. i have posted the code below.
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalFeedback = rs.RecordCount
tbCom.Value = totalFeedback
Set rs = Nothing
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Escalated] = '" & "Yes" & "' AND [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalEsc = rs.RecordCount
tbEsc.Value = totalEsc
Set rs = Nothing
Set rs = New ADODB.Recordset
searchstring = "SELECT * FROM CompD WHERE [Escalated] = '" & "No" & "' AND [Date] >= " & DateFrom & " And [Date] <= " & DateTo
rs.Open searchstring, cn, adOpenStatic
totalNonEsc = rs.RecordCount
tbNonEsc.Value = totalNonEsc
Set rs = Nothing