I have a table with multiple entries for unique UnitNo and Dates (sometimes different notes as it is been filled by different investigators). I want to merge the notes column and Investigator to a single notes and investigation column:
UnitNo Date Notes Investigator
----------------------------------------------------------------------------
232 13/08/15 No major issues Andy Barney
232 13/08/15 Door Defect Andy Barney
781 21/08/15 No defect found John Adams
781 21/08/15 Door Defect Andy Barney
xxx xxxxxxxx xxxxxxxxxxx xxxxxxxxxx
I want to basically get a single record for the records with similar UnitNo and Date and then combine the other two fields in such a way that if it is similar it doesn't duplicate:
UnitNo Date Notes Investigator
----------------------------------------------------------------------------
232 13/08/15 No major issues Andy Barney
Door Defect
781 21/08/15 No defect found John Adams
Door Defect Andy Barney
xxx xxxxxxxx xxxxxxxxxxx xxxxxxxxxx
I have checked different places for the answer and I found this code Allen Browne and Here. However, I receive an error when I use ConcatRelated(xxx) saying that the sub.[xxx] is not defined.
EDIT
Here is my Code for the second part:
Public Function MergeEquinoxImport()
Dim SQL1 As String
Dim qdfNew1 As QueryDef
Dim db As Database
Set db = CurrentDb
SQL1 = "SELECT Sub.[UnitNo],Sub.[Date], ConcatRelated([Notes], [TblPractise], " & _
"[Date]='" & Sub.[Date] & "' And [UnitNo]='" & Sub.[UnitNo] & "') " & _
"FROM (SELECT q.[UnitNo],q.[Date], FROM TblPractise " & _
"AS q Group BY q.[UnitNo],q.[Date],) AS Sub Order " & _
"BY Sub.[UnitNo],Sub.[Date];"
If acbDoesObjExist("Query1", acQuery) Then
DoCmd.DeleteObject acQuery, "Query1"
End If
With db
Set qdfNew1 = .CreateQueryDef("Query1", SQL1)
End With
End Function