The Link I posted in post #40 has examples of both of the above, what have you tried and what is the error?Thank you Pat for good lesson for me.
I know that relationship is wrong.
I only need technical solution how to write Access SQL to create composite key relationship plus 1 to 1 relationship.
And if this is possible?
Best
Jacek
Sub CreateTableX1()
Dim dbs As Database
' Modify this line to include the path to Northwind
' on your computer.
Set dbs = CurrentDb
On Error Resume Next
sqlS = "ALTER TABLE tblCustomers DROP CONSTRAINT NewOne"
dbs.Execute sqlS
On Error GoTo 0
sqlS = "ALTER TABLE tblCustomers ADD CONSTRAINT NewOne FOREIGN KEY (LastName) REFERENCES tblInvoices (LastName) "
' Create a table with two text fields.
dbs.Execute sqlS
End Sub
Sub CreateTableX1()
Dim dbs As Database
' Modify this line to include the path to Northwind
' on your computer.
Set dbs = CurrentDb
On Error Resume Next
sqlS = "ALTER TABLE tblCustomers DROP CONSTRAINT NewOne"
dbs.Execute sqlS
On Error GoTo 0
sqlS = "ALTER TABLE tblCustomers ADD CONSTRAINT NewOne FOREIGN KEY (LastName) REFERENCES tblInvoices (LastName) "
' Create a table with two text fields.
dbs.Execute sqlS
End Sub
sqlS = "ALTER TABLE tblCustomers ADD CONSTRAINT NewOne FOREIGN KEY (FirstName,LastName) REFERENCES tblInvoices (FirstName,LastName) "
sqlS = "ALTER TABLE tblInvoices ADD CONSTRAINT FKLastName PRIMARY KEY ([LastName], [FirstName]) REFERENCES tblCustomers ([LastName], [FirstName])"