I created a button, when clicked, supposed to create a new record on a different form which is bound to table ‘TProduct’.
Values from these text boxes are to be inserted in to new record in Tproduct.
[Txt_ID]
[txt_Version]
[txt_Total_Cost] – a calculated field
[txt_RecipeState ment] – a calculated field
In addition to these fields update, Vendor ID and Vendor Location are fixed as 10000 and NYC if new record is created this way.
I am having trouble with INSERT INTO statement (Syntax Error). When debugged, Access highlighted entire INSERT INTO phrase.
Can someone help me to correct the syntax? Thanks in advance.
Below is my code.
Values from these text boxes are to be inserted in to new record in Tproduct.
[Txt_ID]
[txt_Version]
[txt_Total_Cost] – a calculated field
[txt_RecipeState ment] – a calculated field
In addition to these fields update, Vendor ID and Vendor Location are fixed as 10000 and NYC if new record is created this way.
I am having trouble with INSERT INTO statement (Syntax Error). When debugged, Access highlighted entire INSERT INTO phrase.
Can someone help me to correct the syntax? Thanks in advance.
Below is my code.
Code:
Dim dbs As Database
Set dbs = CurrentDb
Dim strRID As String
Dim strRver As String
Dim strCost As Currency
Dim strStatement As String
strRID = Me.[Txt_ID]
strRver = Me.[txt_Version]
strCost = Me.[txt_Total_Cost]
strStatement = Me.[txt_RecipeStatement]
MsgBox [strRID]
MsgBox [strCost]
MsgBox [strRver]
MsgBox [strStatement]
dbs.Execute " INSERT INTO TProduct " _
& "(productID, ProductVersion, unit$, spec, vendorID, VendorLocation) VALUES " _
& "('" & strRID & "' , '" & strRver & "', '" & strCost & "', '" & strStatement & "', '10000', 'NYC');"
dbs.Close
Comment