DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: DAO Control/Recordset Error

  1. #1
    Join Date
    Dec 2005
    Posts
    13

    DAO Control/Recordset Error

    I am using VB6-SP6 with a backend of Access. I have code to create a recordset and then attach that to a DAO control on a form. Everything works fine except in two instances...

    The first is that if the recordset is completely empty, I get the "Item Not Found in this Collection" error. If I manually enter a record into the database and run the app, it works just fine. The second has to do with when I delete a record from the database and it's the first record in the recordset (as when it performs a delete I tell it to go to the previous record) I get the same issue. I think it has to do with checking the BOF and EOF markers, but I'm guessing I'm not checking them correctly, although the following code fails when setting the DAO control to the recordset.

    My code for setting up the DAO control is as follows:
    Code:
    Dim irs_SubjectRecordset as DAO.Recordset
    
    dao_Subjects.DatabaseName = gdb_Database.Name
    Set irs_SubjectRecordset = gdb_Database.OpenRecordset("Select * From [Subject] Order By [Last Name], [First Name]")
    dao_Subjects.Connect = ";PWD=" & gstr_Password
    Set dao_Subjects.Recordset = irs_SubjectRecordset
    dao_Subjects.Recordset.Requery
    If dao_Subjects.Recordset.BOF = False And dao_Subjects.Recordset.EOF = False Then
            dao_Subjects.Recordset.MoveLast
            dao_Subjects.Recordset.MoveFirst
            dao_Subjects.UpdateControls
        
    End If '
    I'm guessing if I can get this part to work, I can figure out the deletion issue. Any help would be appreciated.

    Thanks,
    The Merg
    Today's problems don't worry me,
    I haven't solved yesterday's yet.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    Can you identify the line of code where the error is occurring?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Dec 2005
    Posts
    13
    Ooops... Sorry about that. It occurs on the line:

    Code:
    Set dao_Subjects.Recordset = irs_SubjectRecordset
    So it does not seem to even give me the chance to check the BOF and EOF properties then. I know I'm missing something simple, but can't think of what it is.

    Thanks,
    The Merg
    Today's problems don't worry me,
    I haven't solved yesterday's yet.

  4. #4
    Join Date
    Dec 2003
    Posts
    2,750
    Does it work OK if you comment out the Connect statement?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  5. #5
    Join Date
    Dec 2005
    Posts
    13
    The form opens without error, but I have no access to the recordset then. In essence, if I create a record and hit save, it tells me there is no current record.

    As I stated, if there is a record already in the database, it will work. It's just when the database is new/empty that I get the error.

    - The Merg
    Today's problems don't worry me,
    I haven't solved yesterday's yet.

Similar Threads

  1. 'On Error Goto' versus 'Try, Catch, Fail'
    By clarence_rollins in forum .NET
    Replies: 21
    Last Post: 09-11-2002, 11:32 AM
  2. Returning errors from SQL Server Stored Procs
    By Khalizan in forum VB Classic
    Replies: 1
    Last Post: 11-28-2001, 02:32 AM
  3. DTS/linked server error #6
    By John M. in forum Database
    Replies: 0
    Last Post: 05-17-2001, 03:01 PM
  4. WinForm Compile Error
    By Robert in forum .NET
    Replies: 1
    Last Post: 10-24-2000, 11:38 AM
  5. Replies: 0
    Last Post: 04-07-2000, 09:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center