I'm using the code below to create an Access table. It works fine but the Primary keys, Field1 and Field2 are not indexed . If I only list one field as the primary key it is created as indexed with no duplicates. Can I create two primary fields and have them both indexed with not duplicates?
Set cat = New ADOX.Catalog
strDb = CurrentProject.Path & "\Testing.mdb"
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & strDb
cat.Create strConnect
'Set connection to currently catalog
Set conn = cat.ActiveConnection
strTable = "TblNew"
conn.Execute "CREATE TABLE " & strTable _
& "(Field1 CHAR (9),Field2 CHAR (10),Field3 CHAR (5)," _
& "CONSTRAINT idxPrimary Primary Key (Field1, Field2));"
Application.RefreshDatabaseWindow
Set cat = New ADOX.Catalog
strDb = CurrentProject.Path & "\Testing.mdb"
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & strDb
cat.Create strConnect
'Set connection to currently catalog
Set conn = cat.ActiveConnection
strTable = "TblNew"
conn.Execute "CREATE TABLE " & strTable _
& "(Field1 CHAR (9),Field2 CHAR (10),Field3 CHAR (5)," _
& "CONSTRAINT idxPrimary Primary Key (Field1, Field2));"
Application.RefreshDatabaseWindow