Results 1 to 8 of 8

Thread: Help with Recordset**RESOLVED**

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    112

    Help with Recordset**RESOLVED**

    Hi

    Using DAO on a Access97 Database I'm using the following statement to open a recordset.

    Code:
    Set RstCust = Dbs2.OpenRecordset("select * from [sales orders] where customerid = '" & RstEnq![CustID] & "'")
    It gives me the runtime error 3021 no current record surely I can select a recordset theat has no records then test for records afterwards. I need to cycle through a list of customers and update there records, there maybe records to update and there may not be but I thought I could open the recordset then check for EF and BOF afterwards. Can anyone see anything wrong with my statement because I can't and I have a very similar recordset statement earlier in the procedure and it works fine

    TIA

    JFK
    Last edited by JFK; Jun 5th, 2003 at 04:35 AM.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    Somwhow, it seems to me that you are missing a quote at the end of the SQL statement.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Posts
    424
    You generally get that error when there are no records in the table at all. The index for the table hasn't been initialized in that case.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    112
    Ephisians there are over 20000 records in the table, just maybe none that the recordset could return.

    Pasvorto which quote and where?

    thanks

    JFK

  5. #5
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Help with Recordset

    Originally posted by JFK
    Code:
    Set RstCust = Dbs2.OpenRecordset("select * from [sales orders] where customerid = '" & RstEnq("CustID") & "'")
    Customer id is text ??
    If so then that should work fine.
    You just need to check the EOF property of the recordset afterwards. If its not true, do the processing...


    Vince
    Last edited by Ecniv; Jun 5th, 2003 at 04:07 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    112
    Ecniv

    Customer id is text but I still get the error message, I don't understand why as usually I get the chance to check BOF and EOF but when I run this it stops at the line setting the recordset.

    I checked that the database that the table is in is being opened and it is (I assume it is as the .ldb file is created when I use the open database method) so getting a bit frustrated now.

    thanks

    JFK

  7. #7
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    The rstEnq("custid") is not on a record then.

    Do you check that there is a record there first??


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2002
    Posts
    112
    Thanks ecniv although I did check that Rstenq had records I hadn't checked that it had gone EOf from previous operations.

    many thanks

    JFK

Posting Permissions

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



Click Here to Expand Forum to Full Width