Originally Posted by
ocampod
My main problem, however, is that when I do that. I get redundant rows in my report which stems from the query. Obviously, this isn't pretty and I would like to find a way to group it without showing duplicate rows.
I don't follow your post completely, but if you're looking to eliminate duplicate rows from a dataset, this function might be useful to you:
Code:
Function DeleteDups(tblName As String)
On Error Resume Next
'******************************************************************************
' *
'Author: Adam Evanovich *
'Date: 11/11/2010 *
'Purpose: Deletes duplicate records in a single table. *
' *
'Arguments: *
'tblName > Your table. *
' *
'******************************************************************************
Dim tempTbl As String
Dim tempSql As String
Dim db As DAO.Database
Set db = CurrentDb
tempTbl = db.TableDefs(tblName).Name
If err.Number = 3265 Then
MsgBox "Table does not exist!"
GoTo Exit_Handle
Else
tempTbl = tblName & "2"
End If
On Error GoTo Err_Handle
tempSql = "SELECT DISTINCT *" & _
" INTO " & tempTbl & _
" FROM " & tblName
db.Execute tempSql, dbFailOnError
db.TableDefs.Delete (tblName)
DoCmd.Rename tblName, acTable, tempTbl
db.TableDefs.Refresh
Exit_Handle:
db.Close
Set db = Nothing
Exit Function
Err_Handle:
MsgBox err.Description
Resume Exit_Handle
End Function '//LL