Working within Access 2007. Struggling to have database give a real time, updated amount of inventory on hand based on shipments/receipts. I was recommended the following code, but it is throwing a compile error.
Private Sub Command62_Click()
'Arguments: ContID = Container to be reported on
' AsOfDate = the date at which quantity is to be calculated
'If missing, all transactions are included
' Return: Quantity on hand. Zero on error.
Dim db As DAO.Database 'current database
Dim rs As DAO.Recordset ' various recordsets
Dim lngContID As Long ' ContID as long
Dim strAsOf As String ' AsOfDate as string
Dim strLasShipRec As String ' Last ship date as string
Dim strDateClause As String 'Date clause to be used in SQL statement
Dim strSQL As String ' SQL statement
Dim lngOnHand As Long 'IOnHand inventory
If Not IsNull(CONTID) Then
'Initialize: Validate and Convert parameters
Set db = CurrentDb()
lngContID = CONTID
If IsDate(AsOfDate) Then
strAsOf = "#" & Format$(AsOfDate, "mm\/dd\/yyyy") & "#"
'Get the LastShipRec date and quantity fo this container
If Len(strAsOf) > 0 Then
strDateClause = "AND (LastShipRec<="&strAsOf&")"
End If
strSQL = "Select Top 1 LastShipRec, Quantity FROM tblContInventory"& "WHERE ((ContID = "&lngContID&")"&strDateClause)&";ORDER BY LastShipRec DESC;"
It is giving an 'end of statement expected' compile at:
strSQL = "Select Top 1 LastShipRec, Quantity FROM tblContInventory"& "WHERE ((ContID = "&lngContID&")"&strDateClause)&";ORDER BY `enter`LastShipRec DESC;"
AND
If Len(strAsOf) > 0 Then
strDateClause = "AND (LastShipRec<="&strAsOf&")"
End If
Would someone be able to point me in the correct direction? How do I correct this error?