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!

RecordSet.Index and .Seek for multiple indexes? 1

Status
Not open for further replies.

Skie

Programmer
Jun 21, 2004
475
US
Is it possible to create and .Index for more than one column?
Code:
With oRS
    .Index = Array("Column1", "Column2", "Column3")
    .Seek "=", Array("Value1", "Value2", "value3")
    If .NoMatch Then
        .AddNew
        .Fields("Column1") = "Value1"
        .Fields("Column2") = "Value2"
        .Fields("Column3") = "Value3"
        .Fields("Column4") = "Value4"
        .Update
    Else
        .Edit
        .Fields("Column4") = "Value4"
        .Update
    End If
End With
 
Instead of usining index and seek, why not create your recordxset based on SQL with a WHERE clause to return on the rows which would be returned by the seek?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
If I use an SQL statement, can I still add and edit values?
 
Yes

You could do it as you are now with rs.edit etc, so long as the recordset returned by your SQL is an updatable recordset.

You can also update via SQL of course, using UPDATE query and/or INSERT query

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
How are ya Skie . . .

Agree with [blue]KenReay![/blue]. Apparently your understanding of index is misaligned! The index [blue]object or property[/blue] can never comprise an array! Hence [blue]KenReay's[/blue] suggestion . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I didn't think I could index for multiple fields, but I thought it might make things easy. But, knowing that I can update from a query, is definately preferable.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top