Access 2007 내에서 작업. 데이터베이스를 가지고 갈 때 어려움을 겪으며 출하/영수증을 기준으로 업데이트 된 인벤토리의 양을 실시간으로 제공합니다. 다음 코드를 권장했지만 컴파일 오류가 발생했습니다.Access 2007, VBA : 컴파일 오류 : 문 끝 예상 됨
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;"
이가주고에서 컴파일 '문장의 끝은 예상'
strSQL = "Select Top 1 LastShipRec, Quantity FROM tblContInventory"& "WHERE ((ContID = "&lngContID&")"&strDateClause)&";ORDER BY `enter`LastShipRec DESC;"
및
If Len(strAsOf) > 0 Then
strDateClause = "AND (LastShipRec<="&strAsOf&")"
End If
누군가가 올바른 방향으로 날 지점 수 있을까? 이 오류를 어떻게 수정합니까?
이 SQL 문은 tblContInventory와 WHERE 사이에도 공백이 필요합니다. '... tblContInventory "&"WHERE ... "를'tblContInventory WHERE ... '로 바꾸십시오. –