myRS.Index = !! how to specify multi field key !!

ckib

Board Regular
Joined
Sep 14, 2005
Messages
219
Hi, I can't figure out the correct syntax to specify a multi-field key. The primary key of the table tblSegment is seg_projectID and seg_ContactID. I've tried separating the fields with commas and also tried using "&", but no luck. Here is a snippet of code:

Set myDB = CurrentDb()
Set myRS = myDB.OpenRecordset("tblSegment", dbOpenTable)
myRS.Index = "seg_projectID, seg_contactID"
myRS.Seek "=", Me!cont_projectID, Me!contactID
If myRS.NoMatch = False Then
myRS.Delete
strText = "Contact removed for project" & strProjectID
MsgBox (strText)
Me!cont_projectID = ""
myRS.Close
Else
MsgBox "Error detected. Segment record not found"
Undo
End If

Oh, I get Runtime error '3800' and 'seg_projectID, seg_contactID' is not an index in this table.
Any help you can provide would be appreciated. Thanks.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,390
Messages
6,124,669
Members
449,178
Latest member
Emilou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top