Results 1 to 4 of 4

Thread: Stupid Question (sql)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Allen, Texas
    Posts
    125

    Stupid Question (sql)

    Ok this is a stupid question and I am killing myself for it but here it goes...

    How do i use a SQL statement to populate a recordset instead of just opening the recordset. I need to sort some data before i load it in.

    Thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Allen, Texas
    Posts
    125

    More info

    Set DB = OpenDatabase(App.Path & "\PNMA.mdb")
    SqlStmt = "SELECT * FROM Genealogy ORDER BY Parent"
    Set RSGene = DB.OpenRecordset("Genealogy", 1)
    RSGene.Open SqlStmt

    Here is the error I get..

    "Object doesn't support this property or method (Error 438)"

  3. #3
    Addicted Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    190
    try this

    Dim rst As New ADODB.Recordset
    Dim Sqlstr as String


    cnn.Provider = 'jour Provider voor .mdb databases access 2000
    cnn.ConnectionString = App.Path & "\Data\dbFakt.mdb"
    cnn.Open
    cmd.ActiveConnection = cnn

    sqlstr = "Select * From jour table"
    cmd..CommandText = sqlstr
    rst.Open cmd

    this should do it.

  4. #4
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313

    No such thing as a stupid question...

    The problem is that you're opening the table and then trying to do it again using your SQL statement. Try this...

    VB Code:
    1. Set DB = OpenDatabase(App.Path & "\PNMA.mdb")
    2. SqlStmt = "SELECT * FROM Genealogy ORDER BY Parent"
    3. Set RSGene = DB.OpenRecordset(SqlStmt , 1)
    4. 'RSGene.Open SqlStmt

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