Dave, try this:
Create a query in your database with this definition:
Code:
SELECT DelTo, Town, PostCode, Vehicle, Driver, DeliveryDate, Count(DelNo) AS DelCount
FROM tblAssign
GROUP BY DelTo, Town, PostCode, Vehicle, Driver, DeliveryDate;
Check the results and save it.
Then use its name (say qryAssignGroup) in your code as below:
Code:
Set rs = db.OpenRecordset("SELECT * FROM qryAssignGroup " _
& "WHERE Driver = '" & mDriver _
& "' And DeliveryDate = #" & mDelDate _
& "# And Vehicle = '" & VehReg _
& "' And DelCount <= " & mDelCount, dbOpenSnapshot)
Export the data to Excel with "one step" method.