createrelation problem

willem
07-11-2001, 12:36 PM
I have two tables one students table and one attendance table i want to create a one to one relation between studentid and monthid , i have a problem grasping the syntaxis of the creating and appending this relation. Can anybody help me? This is the code i have already.


dim tbl1 as tabledef
dim tbl as tabledef
dim relnew as relation

Set tbl1 = CurrentDb().TableDefs("tblStudents")
Set tbl = CurrentDb().TableDefs("januari")
Set relnew = CurrentDb().CreateRelation("leerlingaanwezig", tbl1, tbl, dbRelationUnique)

relnew.Fields.Append relnew.CreateField("leerlingid")
relnew.Fields!monthid.ForeignName = "monthid"

CurrentDb().Relations.Append relnew

CurrentDb().Close

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum