Filter on Recordset - RT Err '3001' Invalid Argument - Any Ideas? 
Author Message
 Filter on Recordset - RT Err '3001' Invalid Argument - Any Ideas?

greets,

im getting an 'Invalid Arg.' error in the following code & cant quite see why
.. is it obvious or am missing something here? :

' Using:
        MS Visual Basic 4.0 Professional Version
' Example is from:
'       Teach Yourself Db Programming w/ VB4 in 21 Days
'       Day 4, Page 77

Private Sub Form_Load()
    '
    ' create data object variables
    Dim dat As Database '// create a database object
    Dim dyn1 As Recordset '// create a dynaset-type object
    Dim dyn2 As Recordset   '// create dynaset-type object
    '
    ' create standard variables
    Dim cDbName As String
    Dim cRecSource As String
    Dim nRecs As Integer
    Dim cFilter As String
'
    ' initialize variables
    cDbName = App.Path + "\biblio.mdb"
    cRecSource = "Titles"
    cFilter = "SELECT * FROM Titles WHERE PubId<25;"
    '
    ' set values
    Set dat = OpenDatabase(cDbName)          '// open the database
    Set dyn1 = dat.OpenRecordset(cRecSource) '// create the recordset
    dyn1.MoveLast               '// move to end of set to force count
    nRecs = dyn1.RecordCount    '// get count
    MsgBox cRecSource + " : " + Str$(nRecs), 0, "Total Records in Set."
    '

' ////////////////////////////////////////////////////////////////////////
    ' create subset of recordset and count records
    Set dyn2 = dyn1.OpenRecordset(cFilter)  ' <~~~ BOMBS OUT HERE
    '                           Runtime Error '3001' - Invalid Argument
' ////////////////////////////////////////////////////////////////////////

    dyn2.MoveLast
    nRecs = dyn2.RecordCount
    MsgBox cRecSource + " : " + Str$(nRecs), 0, "Total Records in 2nd Set."
'// exit program
    End
End Sub

thanx,

Heuy
~~~~~~~~~~~~~~
HeuyWorld
http://www.***.com/



Thu, 03 May 2001 03:00:00 GMT
 Filter on Recordset - RT Err '3001' Invalid Argument - Any Ideas?

Hello Heuy,

The filter property is not a complete select statement. It is more like the
WHERE clause without the word WHERE.

Make this change and try again

......
    ' initialize variables
    cDbName = App.Path + "\biblio.mdb"
    cRecSource = "Titles"
    cFilter = "PubId<25"
    '

HTH

Andrew



Thu, 03 May 2001 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Please Help...Linking MBD's with code -- ERROR 3001 - Invalid Argument

2. ERROR 3001 - "Invalid Argument"

3. OpenRecordset 3001 Invalid Argument error

4. Error 3001 - Invalid argument

5. Error 3001, Invalid Argument, Not all the time!

6. Error 3001: Invalid argument

7. CompactDatabase gives "3001: Invalid Argument"

8. Runtime error '3001'

9. Runtime error '3001'

10. Runtime error '3001'

11. Run-time error '3001'

12. Please help: Run-time error '3001'


 
Powered by phpBB® Forum Software