General discussion
-
Topic
-
Insert using data from form transact sql
LockedI am trying to write a simple query (or so I thought) that takes data from an Access form and inserts it into the database. as far as I can tell my syntax is right but it doen’t seem to be aware of the form. The code is
ALTER PROCEDURE dbo.Add_Product
(
@Product_Code char = [Forms]![frm_main]![Product_Code_Text],
@Product_Desc char = [Forms]![frm_main]![Product_Desc_Text],
@Product_Supplier char = [Forms]![frm_main]![Product_Supplier_Combo],
@Product_manufacturer char = [Froms]![frm_main]![Product_Manufacturer_combo],
@Product_Serial char = [Forms]![frm_main]![Product_Serial_Text],
@Product_Cost money = CONVERT(money, [Forms]![frm_main]![Product_Cost_Text])
@Product_Id bigint = 1 + SELECT MAX(Product_ID) FROM dbo.products
)AS INSERT INTO dbo.Products
(Product_Code, Product_Description, Product_Supplier, Product_Manufacturer, Product_Serial, Product_Cost_Ex_GST, Product_Id)
VALUES (@Product_Code, @Product_Desc, @Product_Supplier, @Product_manufacturer, @Product_Serial , @Product_Cost , @Product_Id)The error I get when trying to save the proceedure is “ADO error: Line 3: Incorrect syntax near ‘!’. Line 10: Incorrect syntax near ‘)’. Must declare the variable ‘Product_Code’
Any pointers in the right direction would be great. I am starting to get the feeling I am going to have to do this in VB.