Open recordset on index

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

I have the following code:

Dim db As Database
Dim rs As Recordset
Dim Qd As QueryDef
Set db = CurrentDb()
Set rs = db.OpenRecordset("Table1", dbOpenDynaset)

Question 01: I want to set the order of this recordset to
one of Table1's indexes. How do I do this?

Questoin 02: If there is a PrimaryKey does it always
default the PrimaryKey index?

Thank you,


Steven
 
Set rs = db.OpenRecordset("Table1", dbOpenDynaset)

Question 01: I want to set the order of this recordset to
one of Table1's indexes. How do I do this?

strSQL = "SELECT ALL * FROM TableI ORDER BY MyIndex"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Questoin 02: If there is a PrimaryKey does it always
default the PrimaryKey index?

If there isn't a primary key then it's not a table. And there is only one
primary key. It is possible to have a primary key that is not called
"PrimaryKey", and/ or another non-primary key called "PrimaryKey", but you
have to work quite hard to achieve it. Does that answer the question?


Hope that helps


Tim F
 
Back
Top