Hi All
The below code works fine except when there is no recorset found then i want to display 0 in the cell but its not doing it. The code just leaves it blank if no recordset found.
Can anyone please help me in this?
![]()
Sub PCount() Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=J:\database.mdb;" strSQL = "select Sum(Pagecount) from tblmain where DateCounted = #" & Format(Date, "dd/mm/yyyy") & "# And Used ='Batched' And Type3 Like '%Backscan'" rs.Open strSQL, cn If Not (rs.BOF = True And rs.EOF = True) Then Sheets("TCF SLIDE").Cells(39, "AW").Value = "Page Count= " & rs.Fields(0).Value Else Sheets("TCF SLIDE").Cells(39, "AW").Value = "0" End If rs.Close cn.Close











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks