S
Samantha
I have a query that compares the OrderDate field from tables Temp and
Quantity. If they are the same, then I want to update the Qty field from
Temp table to Quantity table.
The problem is: I am getting a syntax error on referencing the two fields
(OrderDate) from both tables? Does anyone know what wrong with this code?
Private Sub Command0_Click()
Dim db As Database
Dim rsTemp As Recordset
Dim rsQuantity As Recordset
Dim strSQLqty As String
Dim strSQLtemp As String
Dim strPOID As String
Dim OrderDate As Date
Set db = CurrentDb
strSQLtemp = "SELECT Temp.POID, Temp.OrderDate, Temp.Qty, Quantity.Qty,
Quantity.OrderDate, Quantity.POID"
strSQLtemp = strSQLtemp & " FROM Temp LEFT JOIN Quantity"
strSQLtemp = strSQLtemp & " ON Temp.POID = Quantity.POID"
Set rsTemp = db.OpenRecordset(strSQLtemp, dbOpenDynaset)
With rsTemp
If .RecordCount > 0 Then
.MoveFirst 'move to first record
Do Until .EOF
If ![Temp]![OrderDate] = [Quantity]![OrderDate] Then
.Edit
![Quantity]![Qty] = ![Temp]![Qty]
.Update
Else
Debug.Print ![Temp]![POID]
End If
.MoveNext
Loop
End If
.Close
End With
End Sub
Any help is greatly appreciated! thanks in advance!
Quantity. If they are the same, then I want to update the Qty field from
Temp table to Quantity table.
The problem is: I am getting a syntax error on referencing the two fields
(OrderDate) from both tables? Does anyone know what wrong with this code?
Private Sub Command0_Click()
Dim db As Database
Dim rsTemp As Recordset
Dim rsQuantity As Recordset
Dim strSQLqty As String
Dim strSQLtemp As String
Dim strPOID As String
Dim OrderDate As Date
Set db = CurrentDb
strSQLtemp = "SELECT Temp.POID, Temp.OrderDate, Temp.Qty, Quantity.Qty,
Quantity.OrderDate, Quantity.POID"
strSQLtemp = strSQLtemp & " FROM Temp LEFT JOIN Quantity"
strSQLtemp = strSQLtemp & " ON Temp.POID = Quantity.POID"
Set rsTemp = db.OpenRecordset(strSQLtemp, dbOpenDynaset)
With rsTemp
If .RecordCount > 0 Then
.MoveFirst 'move to first record
Do Until .EOF
If ![Temp]![OrderDate] = [Quantity]![OrderDate] Then
.Edit
![Quantity]![Qty] = ![Temp]![Qty]
.Update
Else
Debug.Print ![Temp]![POID]
End If
.MoveNext
Loop
End If
.Close
End With
End Sub
Any help is greatly appreciated! thanks in advance!