Results 1 to 3 of 3

Thread: What's wrong with this code?

  1. #1

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    What's wrong with this code?

    And how can I fix it?
    Code:
     Dim myDB As Database, myTable As TableDef, myRecordset As Recordset
    
     Set myDB = OpenDatabase("C:\Data\" & InGeo & "ImpData.mdb")
     Set myTable = myDB.TableDefs("MAIN")
     Set myRecordset = myTable.OpenRecordset
     
     myRecordset.Filter = "BATCHNO = '" & BatchNo & "' AND YEAR = '" & FYear & "'"
     Set myRecordset = myRecordset.OpenRecordset
     
     With myRecordset
          .MoveFirst
    etc. etc. I get a message "Operation is not supported for this type of object", in the line myRecordset.Filter = "BATCHNO
    Nick Cook
    VB6 (SP6)

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    1) Have you created the reference from the project menu to the "MICROSOFT DAO OBJECT LIBRARY" properly ?

    2) If you do a debug.print, do the following get returned as you expect them (ie not an extra "\" in the first one for example) :
    • InGeo
    • BatchNo
    • FYear

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550
    Alex - sorry, yes, all that stuff works fine. The problem is this method of applying a filter to the recordset, which, for this method, there's no help for.
    Nick Cook
    VB6 (SP6)

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