How do i convert the code below to Stored Procedure?
This is in SAVE Button
Code:On Error GoTo ErrHandler If Checker = True Then 'Product ID already Exist then save in tblStocktransFile Only 'SEQ = rsStock.Fields("Sequence") oConn.BeginTrans sSQL = "SELECT IsNull(Max(Sequence),0)+1 " & _ "FROM tblStockTransFile " & _ "WHERE ProductID='" & txtProdID.Text & "' AND EntryDate=" & DTEntryDate.Value & "" Debug.Print sSQL oConn.Execute sSQL sSQL = "INSERT INTO tblStockTransFile (ProductID, EntryDate, PurchasePrice,Quantity, Reason)" & _ "VALUES('" & txtProdID.Text & "'," & DTEntryDate.Value & _ ",'" & txtProdPurchasePrice.Text & "','" & txtProdQTY.Text & "','In')" Debug.Print sSQL '" & rsStock.Fields("Sequence") + 1 & "' oConn.Execute sSQL oConn.CommitTrans Else 'Product ID does not Exist so save in both tblStockMasterFile and tblStockTransFile oConn.BeginTrans sSQL = "INSERT INTO tblStockMasterFile(ProductID, ProductName,Unit,ReOrderPoint)" & _ "VALUES( '" & txtProdID.Text & "','" & txtProdName.Text & "','" & txtProdUnit.Text & " ', '" & txtProdReOrderPoint.Text & "')" oConn.Execute sSQL sSQL = "SELECT IsNull(Max(Sequence),0 )+ 1" & _ "FROM tblStockTransFile " & _ "WHERE ProductID='" & txtProdID.Text & "' AND EntryDate=" & DTEntryDate.Value & "" Debug.Print sSQL oConn.Execute sSQL sSQL = "INSERT INTO tblStockTransFile (ProductID, EntryDate, PurchasePrice, Quantity, Reason)" & _ "VALUES('" & txtProdID.Text & "'," & DTEntryDate.Value & ",'" & txtProdPurchasePrice.Text & _ "','" & txtProdQTY.Text & " ','In')" ' Debug.Print sSQL oConn.Execute sSQL oConn.CommitTrans End If


Reply With Quote