Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2

    Unanswered: ADO recordsets aren't being populated

    Hi
    I'm being driven up the wall by a particular problem in Access 2000. I have a database to generate barcodes, and there are a number of occasions when I'm using recordsets to either count records that meet a given criterion, or to loop through them to find another value. The recordsets are being created by the following sub:

    Sub PrimeRST(ByVal Task As String, Optional ByVal Source As String)
    'Take the values provided, and either open the recordset or close it.

    Select Case Task

    Case "Open"

    'Open the recordset
    Set GrstTemp = New ADODB.Recordset
    GrstTemp.Open Source, CurrentProject.Connection, adOpenKeyset, adLockOptimistic


    Case "Close"

    'Close the recordset
    GrstTemp.Close
    Set GrstTemp = Nothing

    End Select

    End Sub

    GrstTemp is a global variable declared as a recordset. "Task" is the literal value, hard-coded into the line that invokes this sub. "Source" is either the name of a query or a variable containing a SELECT SQL statement.
    I've been through several versions, and even if the query/SQL statement returns records, the recordset always ends up with 0 records. I've tried ADO and DAO recordsets, and I've tried declaring this sub as Static. If anyone has any ideas, they'd be gratefully received!

    EDIT
    One of my colleagues has solved this one for me - details in the thread below.
    Last edited by weejas; 02-12-07 at 10:09.

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    What code are you using to determine the # of records?
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2

    Thumbs up

    The code that looks at the number of records is:

    If GrstTemp.BOF and GrstTemp.EOF Then

    GvarCurrent = Null

    Else

    GvarCurrent = Me.txtsfmBarCode

    End If

    As it turns out, a colleague has highlighted what the problem was - my SQL statements were using "*" for wildcards, instead of "%". Having updated all my asterisks to percent signs, I'm now getting error 3075 instead, but I think that I can fix that.

    Thanks looking!

Posting Permissions

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