I have been working a long time on a project using MS Access 2013. One issue i am having is i have very very long "Comments" in tables i need to break down and insert into new tables. Each comment is linked to a "RouteID" and their relationships between the two can be many to many. The main issue i am having is there are duplicate comments in the table i am moving data FROM. There is no need to keep the duplicate "Comments", the only difference in the rows is the "RouteID". Basically i have an OLD comments table and a NEW comments table.
My issue is its not correctly checking if comments from my OLD table are in the NEW table and is creating duplicates.
SOME COMMENTS ARE found to be duplicates, others are not and the size of the comments that are found to NOT BE DUPLICATES vary on size and symbols from short to very long.
Here is some code i have written, i have attempted multiple versions of SQL and VBA/VB6 code, however the result is still the same, duplicate comments are showing up in my new table. Please feel free to critique this regardless if it has to do with my issue or not.
I am aware that some queries can be far far too long to work so i have made a SQL query to compare the TABLE'S together however that also fails and duplicate comments remain. I have checked my code and i do not believe that i am doing the logic incorrectly
Please help! No one seems to know what to do in my circle of friends / professors. I have an idea to take the comments and HASH them and put them into a similar table and use that to check
If Not (rsOLD.EOF And rsOLD.BOF) Then
rsOLD.MoveFirst
Do Until (rsOLD.EOF = True)
TComment = rsOLD(CommentColumn)
TResponse = rsOLD(ResponseColumn)
If Not IsNull(TComment) Then
TComment = Replace(TComment, "'", "''")
SQL = "SELECT Comment, ID FROM Comments WHERE Comment = (SELECT '" & CommentColumn & _
"' FROM CommentsOld WHERE (CommentsOld.ID = " & rsOLD!ID & "));"
'SQL = "SELECT Comment FROM Comments" & _
' " INNER JOIN CommentsOld" & _
' " ON Comments.Comment = CommentsOld." & CommentColumn & _
' " WHERE CommentsOld.ID = " & rsOLD!ID & ";"
Set rsCHECK = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)
If (rsCHECK.EOF And rsCHECK.BOF) Then 'IF COMMENT DOES NOT EXIST, NOTHING FOUND
I have attempted to work with a bool function that loops through a recordset, but the BigO of the loops is far to large to complete in a reasonable amount of time given the size of the records in each table.