Open recordset on index

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
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top