Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index Error

Status
Not open for further replies.

121410

Programmer
Jun 6, 2001
5
VN
Here is my problem

I use VB6.0 and Access 2000
My Code is
Set cn = new ADODB.Connection
Set rs = new ADODB.Recordset

With cn
.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "Test.mdb"
.Open
End With

rs.Open "Select * from Test",cn, adOpenDynamic, adLockOptimistic
rs.Index = "Test"

When run above code, error " Member or data member not found" occur at "Index" property

Can you tell me why and how to correct it???
 
Don't know if this is it, but the index must be previously defined in the DB, either via ADOX or from within Access.
If you are trying to referense a field that is not previosly defined as an index, this will give you a runtime error.

Also, I noted you are using Test both as the field name, and as the table name. This is not a problem, but you do have a field within the table Test that has the name Test, don't you? (Just checking. :)

Good Luck
-Mats Hulten
 
Actually, "Test" appears to refer to:
[tab]The db name
[tab]The Table Name
[tab]The Index Name.

Field name(s) are not explicitly given.

but MatsHulten's point is still valid

Each of the Objects with the NAME "Test" must be re-incarnated (have a 'prior') existance.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Now my Code is

Code:
Set cn = new ADODB.Connection
Set rs = new ADODB.Recordset

With cn
    .ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "myDatabase.mdb"
     .Open
End With
     
rs.Open "Select * from myTable",cn, adOpenDynamic, adLockOptimistic
rs.Index = "myField"

When run above code, error " Member or data member not found" still occur at "Index" property

Can you tell me why?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top