-
Hi
I have the code to create a table dynamically but I need to know how to link a feild in one table to another table. I think I need to use the REFERENCES part but I have no idea how it works.
Also does any body know of a good reference manual / book for SQL (so I don't bother U lot as much! :) )
Cheers Guys and Gals
Geoff ;)
------------------
-
You can do it like this:
Dim NewRelation As Relation
Set NewRelation = db.CreateRelation("ReferralContactsTransactions", _
"ReferralContacts", "Transactions", dbRelationDontEnforce)
NewRelation.Fields.Append NewRelation.CreateField("RefContactID")
NewRelation.Fields("RefContactID").ForeignName = "RefContactID"
db.Relations.Append NewRelation
-
Hi Geoff
You should determine references while creating a table.
CREATE TABLE "dbo"."TableX" (
"Id" "int" IDENTITY (1, 1) NOT NULL ,
"StringValue" varchar (20) NOT NULL ,
) REFERENCES "dbo"."Join" (
"Join_Id"
)
)
GO
-