I've got my db for generating basic invoices, however the initial design was extremely rushed and consequently it's extremely inefficient.
Basically, when a new order is created; a query inserts a record for EVERY product in tblProducts to tblOrderDetails and the form just updates the quantity in tblOrderDetails and then the report only displays records with qty >1
The result of this is an average of 600 superfluous records per order in tblOrderDetails - a total of 150000+ more than needed.
Now that i've got more time I'm trying to redesign the form.
I've managed to get it to create a record in tblOrderDetails only when the qty is updated on the form using the following:
the only problem is that this creates 2 records - one of them with a null OrderID
results being:
DetailID OrderId Product Qty ToFollow ToFollowQty
151101 5582 14 No
151102 350 5582 14 No
everything seems straightforward enough - i can't figure out why this is happening.
any ideas?
Basically, when a new order is created; a query inserts a record for EVERY product in tblProducts to tblOrderDetails and the form just updates the quantity in tblOrderDetails and then the report only displays records with qty >1
The result of this is an average of 600 superfluous records per order in tblOrderDetails - a total of 150000+ more than needed.
Now that i've got more time I'm trying to redesign the form.
I've managed to get it to create a record in tblOrderDetails only when the qty is updated on the form using the following:
Code:
Private Sub txtQty_AfterUpdate()
Dim strSql As String
If IsNull(Me.txtQty) Then
strSql = "DELETE tblOrderdetails.*" & _
"FROM tblOrderdetails " & _
"WHERE tblOrderdetails.Product = " & Me.stampAutoID & ";"
Else
strSql = "INSERT INTO tblOrderDetails (OrderID, Product, Qty) " & _
" Values (" & Me.Parent.OrderId & "," & Me.stampAutoID & " , " & Me.txtQty & ");"
End If
CurrentDb.Execute strSql
End Sub
results being:
DetailID OrderId Product Qty ToFollow ToFollowQty
151101 5582 14 No
151102 350 5582 14 No
everything seems straightforward enough - i can't figure out why this is happening.
any ideas?