Hi Guy's, i have spent days on this and can't figure out why i am returning incorrect dates, some delivery dates and collection dates don't match the dates in the tables for the searched (double click event)
I think have have now gone past myself to be able to rectify, if you guy's can see something and kindly simplify this would be totally appreciated ?
In the iItemNo field, there is always 6 digits followed by hyphen and a client name something like
123456-Smith
987654-Jones
WHILE IT IS NOT IDEAL, I CHANGED iLiftNo from Integer to Long but didn't' change all of the code, I can do that if i thought that was causing the incorrect dates problem!
Code:
iItemNo = Left(Me.ItemNo, 6)strMFG = iItemNo 'Currently doing nothing
If IsNull(iItemNo = DLookup("ItemNo", "tblStock", "ItemNo Like ""*" & iItemNo & "*""")) Then
strBody = "There are No MFG No: " & iItemNo & " " & "In Stock!" & "|"
End If
If Not IsNull(iItemNo = DLookup("ItemNo", "tblStock", "ItemNoLike ""*" & iItemNo& "*""")) Then
iSortNo = DLookup("SortNo", "tblStock", "ItemNo Like ""*" & iItemNo& "*""")
strType = DLookup("ItemType", "tblStock", "[SortNo] = " & iSortNo)
Set rs = CurrentDb.OpenRecordset("Select * From tblStock WHERE ItemType = '" & strType & "'")
Do Until rs.EOF
If rs.Fields("NewQty") <> "0" Then
strAV = "Available Qty " & FontStart & "<B>" & "<font color='black'>" & rs.Fields("NewQty") & "</B></font>"
End If
If rs.Fields("NewQty") = "0" Then
strAV = "Available Qty " & FontStart & "<B>" & "<span style='background:yellow'>" & rs.Fields("NewQty") & "</font></B></span>"
End If
strBody = strBody & rs.Fields("ItemType") & " - " & "MFG No: " & rs.Fields("ItemNo") & " - " & "Warehouse Qty: " & rs.Fields("StartQty") & _
" - " & "Allocated Qty: " & rs.Fields("AllocatedQty") & " - " & strAV & "|"
rs.MoveNext
Loop
End If
Set rs2 = CurrentDb.OpenRecordset("Select * From tblEdit WHERE ItemNo Like ""*" & iItemNo & "*"" ORDER BY tblEdit.DelTo;")
Do Until rs2.EOF
If rs2.Fields("Status") = "Collection" Then
strStatus = DLookup("Status", "tblCollections", "ItemNo Like ""*" & iItemNo & "*""")
If Right(strStatus, 3) = "ted" Then ' Collected (Already Shipped)
dteColDate = DLookup("CollectedDate", "tblCollections", "[ItemNo] Like ""*" & iItemNo & "*""")
strValue = " " & " " & rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus & " - " & Format(dteColDate, "ddd-dd-mmm-yyyy")
End If
If Right(strStatus, 3) = "ion" Then ' Collection (Not shipped Yet)
dteColDate = Null
ShipDate = "Waiting Collection"
strValue = " " & " " & rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus & " - " & "Waiting Collection"
End If
End If
If rs2.Fields("Status") = "Delivery" Then
strStatus = rs2.Fields("Status")
dteDelDate = DLookup("DeliveryDate", "tblAssign", "ItemNo Like ""*" & iItemNo & "*""")
strValue = " " & " " & " " & rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus & " - " & Format(dteDelDate, "ddd-dd-mmm-yyyy")
End If
If rs2.Fields("Status") = "Planning" Then
strStatus = rs2.Fields("Status")
strValue = rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus & " - " & "Not Shipped"
End If
If IsNull(rs2.Fields("Status")) Then
strValue = rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus & " - " & "No Status"
End If
If rs2.Fields("Status") = "On Hold" Then
strDate = ""
strStatus = strMark & rs2.Fields("Status") & strMarkEnd
strValue = rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus
End If
If rs2.Fields("Status") = "Friday" Then
strStatus = "Due In: " & rs2.Fields("Status")
strDate = ""
strValue = rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus
End If
If rs2.Fields("Status") = "Monday" Then
strStatus = "Due In: " & rs2.Fields("Status")
strDate = ""
strValue = rs2.Fields("DelTo") & " - " & rs2.Fields("PONumber") & " - " & rs2.Fields("SONumber") & " - " & UCase(rs2.Fields("ItemNo")) & " - " & Chr(9) & strStatus
End If
sBody = sBody & strValue & "|"
rs2.MoveNext
Loop
Debug.Print sBody
strA = "Hello, hope you are safe and well.|"
strB = "This listing is current stock details for " & strType & "|"
Set myItem = myApp.CreateItem(olMailItem)
Set OutAccount = myApp.Session.Accounts.Item(1)
With myItem
.subject = strType & " " & iItemNo & " Stock Details"
.To = ""
.HTMLBody = FontStart & Replace(strA, "|", "<br>") & "<br>" & "<br>" & Replace(strB, "|", "<br>" & "<br>") & "<br>" & "<br>" & BoxStart & "<br>" & _
Replace(strBody, "|", "<br>" & "<br>") & "<br>" & BoxEnd & "<br>" & "<br>" & _
FontStart & BoxStart & "<br>" & strMFG & " History" & "<br>" & "<br>" & Replace(sBody, "|", "<br>" & "<br>") & "<br>" & BoxEnd & "<br>" & "<br>" & _
wkr & "<br>" & "<br>" & _
UserfName & FontEnd & "<br>" & "<br>" & _
"<P><IMG border=0 hspace=0 alt='' src='file://T:/Logo Media/" & SigFile & "' align=baseline></P>" & "<br>" & "<br>" & _
"<FONT color=#00008B>" & eDisc & "<br>" & "<FONT color =#00008B>" & eDisc2
.SendUsingAccount = OutAccount
.ReadReceiptRequested = True
.Display
End With
End If