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
Printable View
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
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)"
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.
The problem is that you're opening the table and then trying to do it again using your SQL statement. Try this...
VB Code:
Set DB = OpenDatabase(App.Path & "\PNMA.mdb") SqlStmt = "SELECT * FROM Genealogy ORDER BY Parent" Set RSGene = DB.OpenRecordset(SqlStmt , 1) 'RSGene.Open SqlStmt