+ Reply to Thread
Results 1 to 4 of 4

When no recordset found then display 0 in the cell.

Hybrid View

aman1234 When no recordset found then... 06-19-2014, 08:28 AM
ARGK Re: When no recordset found... 06-19-2014, 09:24 AM
aman1234 Re: When no recordset found... 06-19-2014, 10:43 AM
ARGK Re: When no recordset found... 06-19-2014, 11:45 AM
  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    When no recordset found then display 0 in the cell.

    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

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: When no recordset found then display 0 in the cell.

    Hi
    Do you have "display zero values" switched on in your Excel Options?
    Tony

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: When no recordset found then display 0 in the cell.

    How to check that whether the "Display zero values" are switched on or not??? Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: When no recordset found then display 0 in the cell.

    Hi

    Display or hide all zero values on a worksheet
    1.On the Tools menu, click Options, and then click the View tab.
    2.Do one of the following:
    To display zero (0) values in cells, select the Zero values check box.
    To display zero values as blank cells, clear the check box.
    Good luck.
    Tony

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Search CELL-A for one or two letters and display the found letters in CELL-B
    By adamtre in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2014, 02:43 AM
  2. Replies: 3
    Last Post: 10-04-2013, 05:20 PM
  3. [SOLVED] Display Cell if Text is Found Within cell
    By DJTHERI in forum Excel General
    Replies: 3
    Last Post: 04-25-2012, 11:36 AM
  4. [SOLVED] Recordset's RowID as part of Recordset
    By Trip in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2005, 06:55 PM
  5. [SOLVED] RecordSet object - Cannot get help file to display
    By Alan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2005, 12:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1