Hello Everyone
I have SaleInvoice MainForm related with SubForm , and I have another table its name is Details , I want when I update data in MainForm and SubForm , and then click on "cmdButton" automatically update data in table name Details
I made code INSERT INTO , but Update isn't work
This is INSERT INTO :
Code:
If DLookup("[id]", "details") = [SaleID] Then Exit Sub
Else
DoCmd.RunSQL "INSERT INTO Details ( ID, sDate, CustomerName, ItemsName, Qy, Price, Total )SELECT Sale.SaleID, Sale.SaleDate, Sale.CustName, Sub.Items, Sub.Qy, Sub.Price, Sub.Total FROM Sale INNER JOIN Sub ON Sale.SaleID = Sub.SubID"
End If
UPDATE :
Code:
DoCmd.SetWarnings False CurrentDb.Execute "UPDATE Details " & _
"SET ID =" & Me.SaleID & _
", sDate = #" & Me.SaleDate & "#" & _
", CustomerName ='" & Me.CustName & "'" & _
", ItemsName ='" & Me.Sub!Items & "'" & _
", Qy = " & Me.Sub!Qy & _
", Price =" & Me.Sub!Price & _
", Total =" & Me.Sub!Total & _
"WHERE ID = " & Me.SaleID
DoCmd.SetWarnings True
Can someone help me , please ?