Results 1 to 4 of 4
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Recordset not returning records

    I am trying to get two fields from a table so I can update one of them based on the other.

    Set db = CurrentDb
    strSQL = "SELECT tblInvoiceDetails.companyid, tblInvoiceDetails.invoiceid " _
    & "FROM tblInvoiceDetails WHERE [invoiceid] is null "

    Set rs = db.OpenRecordset(strSQL)

    CustCnt = rs.RecordCount



    When I check CustCnt to see it worked it CustCnt = 1 but my companyid field is null i.e. no records were returned.

    any help much appreciated.

  2. #2
    Join Date
    Sep 2010
    Posts
    1
    If you want records where the companyid is null, try this:
    Set db = CurrentDb
    strSQL = "SELECT tblInvoiceDetails.companyid, tblInvoiceDetails.invoiceid " _
    & "FROM tblInvoiceDetails WHERE [companyid] is null "

    Set rs = db.OpenRecordset(strSQL)

    CustCnt = rs.RecordCount

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,043
    Hi,

    when you're working with recordsets you always have to move to the last record before you can do the count. You can check on empty recordsets by checking if .BOF (begin of file) and .EOF (end of file) are both true at the same time.

    grNG

  4. #4
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Noella, that got me the correct count - Thanks. I am still getting empty for the CompanyId field I need to use this field to do my loop. Is my code for getting the value of the companyId incorrect?

    CustId = CompanyId

    Thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-19-2011, 10:55 PM
  2. Replies: 12
    Last Post: 10-15-2010, 10:03 AM
  3. Returning multiple records Isn't what I need
    By frobro390 in forum Queries
    Replies: 6
    Last Post: 09-21-2010, 06:24 PM
  4. Combo box returning only about 1000 records
    By cjbuechler in forum Forms
    Replies: 12
    Last Post: 06-30-2010, 08:27 AM
  5. Replies: 0
    Last Post: 08-04-2009, 09:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums