Hi i have this code that Adds data into a Purchase Order Header, then displays the PONumber in a Message Box and finally Updates the PONo within the Order made which can be many records. The code i have is as follows;
I have tested the code line by line and its works upto the point of the Update part starting with rst2.
Can anybody tell me why it doesn't update the ordlin table. No errors occur! Thanks in advance.
Code:
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT * FROM pordhdr")
With rst
.AddNew
!SuppNo = Me.txtSuppNo
!PODate = [Forms]![frmCustomerOrderForm]![sfrmSOHeader]![OrderDate]
!DueDate = [Forms]![frmCustomerOrderForm]![sfrmSOHeader]![DueDate]
.Update
End With
'Find the NEW PONo just Assigned to the pordhdr
'Display Message with PONo Created
rst.MoveLast
POMsg = MsgBox("Purchase Order " & rst!PONo & " Has Been Created. ", vbOKOnly, "Purchase Order Created")
'UPDATE the PONo Field (Based on SuppNo and OrderNo with the last PONo above) within the ordlin Table therefore Assigning the Stock Details with a Purchase Order
Set rst2 = db.OpenRecordset("SELECT * FROM ordlin")
rst2.Edit
strSQL = "UPDATE ordlin SET [PONo] = '" & rst!PONo & "' WHERE ([ordlin.OrderNo] = [forms]![frmPOGenerator]![txtOrderNo] And [ordlin.SuppNo] = [forms]![frmPOGenerator]![txtSuppNo] AND ((ordlin.PONo) Is NULL))"
DoCmd.RunSQL strSQL
rst2.Update
rst.Close
rst2.Close
Can anybody tell me why it doesn't update the ordlin table. No errors occur! Thanks in advance.
Comment