I am attempting to get comfortable with the Seek Method.
The sample for the Northwind database uses this code (much simplified):
Dim dbs as Database
Dim rst as Recordset
Set dbs=OpenDatabase(path to Northwind database)
set rst=dbs.OpenRecordset("Customers")
rst.Index = "LastName"
Do While Not rst.EOF
MsgBox !LastName
rst.MoveNext
Loop
rst.Close
dbs.Close
This works fine but I have a couple questions.
If I Set dbs = CurrentDb and open a table-type Recordset, it doesn't work (Operation not supported for this type of Object).
If I Set dbs = OpenDatabase(my database), then open a table-type RecordSet, it does work.
Why can I not simply use CurrentDb as the database?
Also:
If I mimic the sample code, and 'Open' my database, it works fine.
I am having trouble understanding why I must 'Open' a database file for this to work.
AND...
I have found that some of my 'Indexed' fields issue an error stating that 'this field is not a member of the Indexes Collection', and that some work fine.
When creating a table, do not the fields that you 'Index' become members of the Indexes Collection?
What gives?
Confusion...blah
The sample for the Northwind database uses this code (much simplified):
Dim dbs as Database
Dim rst as Recordset
Set dbs=OpenDatabase(path to Northwind database)
set rst=dbs.OpenRecordset("Customers")
rst.Index = "LastName"
Do While Not rst.EOF
MsgBox !LastName
rst.MoveNext
Loop
rst.Close
dbs.Close
This works fine but I have a couple questions.
If I Set dbs = CurrentDb and open a table-type Recordset, it doesn't work (Operation not supported for this type of Object).
If I Set dbs = OpenDatabase(my database), then open a table-type RecordSet, it does work.
Why can I not simply use CurrentDb as the database?
Also:
If I mimic the sample code, and 'Open' my database, it works fine.
I am having trouble understanding why I must 'Open' a database file for this to work.
AND...
I have found that some of my 'Indexed' fields issue an error stating that 'this field is not a member of the Indexes Collection', and that some work fine.
When creating a table, do not the fields that you 'Index' become members of the Indexes Collection?
What gives?
Confusion...blah