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

Compound key using DAO? 1

Status
Not open for further replies.

gwar2k1

Programmer
Apr 17, 2003
387
GB
Hey, how can I make a compound key for a relational database using DAO in VB6? It wont let me append more than one key per table... is it possible?

Thanks in advance

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
You're not creating multiple Primary Keys, just one that includes several fields.
Create the index and set it as Primary, Unique, what have you. Add the fields to be included in your Primary Key to your index then add the index to the table.
 
Ah bravo. Commer seperated i take it? Cheers and thanks for the speedy response!

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Well, I'm not 100% sure what you mean by comma separated but, you don't add multiple fields to an index by separating them with commas. More like:
Set idxPrimary = tdfTable.CreateIndex("PrimaryKey")
Set fldField = idxPrimary.CreateField("Field1",dbInteger)
idxPrimary.Fields.Append fldField
Set fldField = idxPrimary.CreateField("Field2",dbText, 10)
idxPrimary.Fields.Append fldField
idxPrimary.Unique = True
idxPrimary.Primary = True
tdfTable.Indexes.Append idxPrimary
 
ah fair play =D yeah i think you got the jist of what i meant

.append ("x", "y", "z")

thanks =D

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top