G
Guest
I have three tables: Classes, Students, and ClassStudentLookup. I want to
populate the Lookup table from the other two tables using an Orthogonal
query. If Classes has 3 records and students has three records, I want the
Lookup table to contain 9 records. Student, Class is the Primary key in this
table.
I am using the following code:
Dim adoCmd As New ADODB.Command
adoCmd.ActiveConnection = CurrentProject.Connection
adoCmd.CommandType = ADODB.CommandTypeEnum.adCmdText
adoCmd.CommandText = "INSERT INTO StudentClassLookup ( Class, Student )
SELECT Classes.Class, Students.Student FROM Classes, Students;"
adoCmd.Execute
This code runs fine if StudentClassLookup table is empty. It returns a
duplicate values in index error if a record already exists. What I need is a
way to either (1) have the execute method execute for those records that
don't already exist or (2) find a way to tweak the query so that it makes the
Execute method happy. Any help will be appreciated.
populate the Lookup table from the other two tables using an Orthogonal
query. If Classes has 3 records and students has three records, I want the
Lookup table to contain 9 records. Student, Class is the Primary key in this
table.
I am using the following code:
Dim adoCmd As New ADODB.Command
adoCmd.ActiveConnection = CurrentProject.Connection
adoCmd.CommandType = ADODB.CommandTypeEnum.adCmdText
adoCmd.CommandText = "INSERT INTO StudentClassLookup ( Class, Student )
SELECT Classes.Class, Students.Student FROM Classes, Students;"
adoCmd.Execute
This code runs fine if StudentClassLookup table is empty. It returns a
duplicate values in index error if a record already exists. What I need is a
way to either (1) have the execute method execute for those records that
don't already exist or (2) find a way to tweak the query so that it makes the
Execute method happy. Any help will be appreciated.