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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Index from SQL Server table with code in vba

Status
Not open for further replies.

jcarneir

Programmer
May 17, 2001
26
0
0
VE
Hi,

I have a vba code that open an access table. Then using a index (3 fields in the index), I can move record by record and perform change in some fields.

This week I have migrate this table to a SQL SERVER Dataase and the vba code in the access database don't work anymore because the index belongs to an external database.

I can open from code both the SQL SERVER Database and table

by:
Set SQLDB = DBEngine.Workspaces(0).OpenDatabase("", True, False, ODBCstring)
set SQLTable=SQLDB.Openrecordset("ODBCTable")

but SQLTable.Index is not valid
 
Perhaps:

set SQLTable=SQLDB.Openrecordset("Select * from ODBCTable order by Field1, Field2, Field3")
 
I think this approach have some problems:

1) I need time to order a table that have an Index yet.
2) The openrecordset creates a photo of the table. I need apply the changes in the records.

thx
 
Question: If the index is unique, can I omit the rst.Index="UniqueIndex"?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top