Sorry, what i should have stated sDamage isn't a field, it's a string from an inputbox set of options
Code:
iCondition = InputBox("Enter The Condition Of Your Images ?" & vbCrLf & vbCrLf & _
Chr(149) & " 1 " & Chr(149) & "Good, No Visible Damage" & vbCrLf & vbCrLf & _
Chr(149) & " 2 " & Chr(149) & "Good, Packaging Damage" & vbCrLf & vbCrLf & _
Chr(149) & " 3 " & Chr(149) & "Marked, Very Light Damage" & vbCrLf & vbCrLf & _
Chr(149) & " 4 " & Chr(149) & "Marked, Heavy Damage", "ENTER CONDITION", "1")
Select Case iCondition
Case Is = 1
sDamage = "Good, No Visible Damage"
Case Is = 2
sDamage = "Good, Packaging Damage"
Case Is = 3
sDamage = "Marked, Very Light Damage"
Case Is = 4
sDamage = "Marked, Heavy Damage"
End Select
So the target is to:
Loop through a set of records on 1 particular postcode
Excel Sheet
If 3 records for that postcode, add the data in from recordset rows 2,3,4 because row 1 is header
then update the condition column (F) according to the SO / item no, this is from iCondition Variable
Have now changed the recordset with these fields so i can use CopyFromRecordset option
i have and do use this option elsewhere but i was thinking i am trying to update this sheet twice, once from rs then update again from iCondition ?
now adjusted to this:
NOTE: not changed to CopyFromRecordset yet, just trying to loop it but can change
Code:
sSQL = "SELECT tblEdit.ShipmentDate, tblEdit.DelTo, tblEdit.PostCode, tblEdit.SONumber, tblEdit.ItemNo " _
& "From tblEdit " _
& "WHERE (((tblEdit.ShipmentDate)=#" & dtShipDate & "#) AND ((tblEdit.PostCode)='" & strPC & "'));"
Set rs = CurrentDb.OpenRecordset(sSQL)
With rs
Do Until rs.EOF
strSL = strSL & rs.Fields("SONumber")
strMFG = strMFG & rs.Fields("ItemNo")
dtShipDate = dtShipDate & rs.Fields("ShipmentDate")
strPostCode = strPostCode & rs.Fields("PostCode")
sDelTo = sDelTo & rs.Fields("DelTo")
rs.MoveNext
Loop
End With
With xlWS
intLR = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To rs.RecordCount
xlWS.Range("A" & intLR + 1) = dtShipDate 'RS
xlWS.Range("B" & intLR + 1) = sDelTo 'RS
xlWS.Range("C" & intLR + 1) = strPostCode 'RS
xlWS.Range("D" & intLR + 1) = strSL 'RS
xlWS.Range("E" & intLR + 1) = strMFG 'RS
xlWS.Range("F" & intLR + 1) = sDamage' String From iCondition
xlWS.Cells.EntireColumn.HorizontalAlignment = xlLeft
Next i
xlWB.Save
xlWB.Close
apXL.Quit
End With