Hi All
I'm trying to finally bridge the gap (or chasm rather) and start learning how to do SQL commands in VBA.
What i'm trying to do is a simple invoice system where my Form selects the products from tblProducts and then creates a record in tblOrderDetails with Product AutoID from the current form record, and a QTY from a textbox on the form.
So, i need to SELECT the product - in this case "StampAutoID" (PK of current record) to insert but I also need the VALUE for Qty from the text box - "txtQty"
I'm already guessing from the syntax that it's doomed from the get go;
but I really want to be able to get my head around it, as my brain turns to mush every time i try to learn something new
Any ideas?
I'm trying to finally bridge the gap (or chasm rather) and start learning how to do SQL commands in VBA.
What i'm trying to do is a simple invoice system where my Form selects the products from tblProducts and then creates a record in tblOrderDetails with Product AutoID from the current form record, and a QTY from a textbox on the form.
So, i need to SELECT the product - in this case "StampAutoID" (PK of current record) to insert but I also need the VALUE for Qty from the text box - "txtQty"
Code:
Private Sub txtQty_AfterUpdate()
Dim strsql As String
strsql = "INSERT INTO tblOrderDetails (Product, Qty)" & _
"SELECT StampAutoID (**?!current record on form?!**), = '" & _
VALUE = '" & Forms!frmOrderFrame!frmProducts!txtQty & "'"
DoCmd.RunSql strsql
but I really want to be able to get my head around it, as my brain turns to mush every time i try to learn something new
Any ideas?
Last edited: