B
blobb
Hi. I posted this question a week or so ago but never got a response, so I
thought that I would attempt again with a different approach.
What I am attempting to do is create a link table [Contact Types] that has
three fields in it: ContactType1, ContactID, and ContactID2. I want to move
the unique identifier: Contacts.ContactID into ContactID and the related
records ContactID into ContactID2. The stumbling block that I am facing is
that Subject 001 may be connected to Subject 250 and 270 in [Contacts]. I
have created another unique identifier Contacts.UniqueID that concatenates
the ContactID from the original source (e.g., Subject 001) and a counter
(used for other purposes). I am attempting to find all records that are
related to the original source (e.g., 001) and then move both 001 into
[Contact Types].ContactID and the related records ContactID (250 & 270) into
[Contact Types]ContactID2. The SQL subquery below works by itself but when
I move it into VBA (as shown below) the UniqueID field is always empty.
Could someone help?
LSQL = LSQL & "(INSERT INTO [Contact Types](ContactType1, ContactID,
ContactID2) "
LSQL = LSQL & "VALUES ("
LSQL = LSQL & "Offspring" & "," & IndexID & "," & NewbornID
LSQL = LSQL & "IN "
LSQL = LSQL & "(SELECT ContactID AS NewbornID "
LSQL = LSQL & "FROM Contacts "
LSQL = LSQL & "WHERE LEFT(" & UniqueID & ",3) = " & IndexID & "))"
thought that I would attempt again with a different approach.
What I am attempting to do is create a link table [Contact Types] that has
three fields in it: ContactType1, ContactID, and ContactID2. I want to move
the unique identifier: Contacts.ContactID into ContactID and the related
records ContactID into ContactID2. The stumbling block that I am facing is
that Subject 001 may be connected to Subject 250 and 270 in [Contacts]. I
have created another unique identifier Contacts.UniqueID that concatenates
the ContactID from the original source (e.g., Subject 001) and a counter
(used for other purposes). I am attempting to find all records that are
related to the original source (e.g., 001) and then move both 001 into
[Contact Types].ContactID and the related records ContactID (250 & 270) into
[Contact Types]ContactID2. The SQL subquery below works by itself but when
I move it into VBA (as shown below) the UniqueID field is always empty.
Could someone help?
LSQL = LSQL & "(INSERT INTO [Contact Types](ContactType1, ContactID,
ContactID2) "
LSQL = LSQL & "VALUES ("
LSQL = LSQL & "Offspring" & "," & IndexID & "," & NewbornID
LSQL = LSQL & "IN "
LSQL = LSQL & "(SELECT ContactID AS NewbornID "
LSQL = LSQL & "FROM Contacts "
LSQL = LSQL & "WHERE LEFT(" & UniqueID & ",3) = " & IndexID & "))"