Hi orange, Paul, tried changing to Pauls suggestion and getting syntax error, i always though an extra Asterix is required to close the criteria ?
So this is the result after trying to change to Pauls
I will need to add some dummy records to show if that was needed as what i have is real data, I will replace the strFirstWord with my user name
Code:
strFullName = Split(Me.DelTo)strFirstWord = Trim(strFullName(0))
Debug.Print strFirstWord
'strSQL = "SELECT COUNT(*) AS PostcodeCount" _
& " FROM tblEdit2" _
& " WHERE ShipmentDate = #" & Format(dtShipWeek, "mm/dd/yyyy") & "#" _
& " AND DelTo Like ""*" & strFirstWord & "*"""
strSQL = "SELECT tblEdit2.PostCode, COUNT(*) AS PostcodeCount" _
& " FROM tblEdit2" _
& " WHERE ShipmentDate = #" & Format(dtShipWeek, "mm/dd/yyyy") & "#" _
& " AND DelTo Like " & strFirstWord & "*" _
& " GROUP BY tblEdit2.PostCode, tblEdit2.DelTo"
Debug.Print strSQL
Set rs = CurrentDb.OpenRecordset(strSQL)
With rs
Do While Not rs.EOF
intPCQty = rs!PostcodeCount
rs.MoveNext
Loop
End With
Debug.Print strSQL & vbCrLf & _
intPCQty
Stop
Immediate Window
Code:
DMTDave
SELECT tblEdit2.PostCode, COUNT(*) AS PostcodeCount FROM tblEdit2 WHERE ShipmentDate = #08/22/2025# AND DelTo Like DMTDave* GROUP BY tblEdit2.PostCode, tblEdit2.DelTo