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 ... 'に置き換えてみてください。 –