We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Private Sub cmdSave_click() Dim i As Integer Dim cn As ADODB.Connection Call OPEN_CON(cn, "MyProject", "Winpos") For i = 1 To grid.Rows - 1 Call save_Table(cn, grid.TextMatrix(i, 0), grid.TextMatrix(i, 1), grid.TextMatrix(i, 2)) Next Set cn = Nothing MsgBox "Done" grid.Clear End Sub Public Sub save_Table(cn As ADODB.Connection, Pckcode As String, Desc As String, Deduct As Double) Dim sql As String sql = "SELECT SH2.ProCode, MAX(SH2.The_Date) AS The_Date " & _ "into #Temp " & _ "FROM stocks_History AS SH2 " & _ "where SH2.procode in (SELECT M3.Procode FROM Myset AS M3 inner JOIN Package AS P3 on P3.GCode = M3.GCode and P3.Pckcode = '" & Pckcode & "' )" & _ "GROUP BY SH2.ProCode " & _ "insert into stocks_History(Procode, description, Outpro, Balance, The_date) " & _ "select SH.Procode, SH.description, SH.outpro - (M.Qty * " & Deduct & ") - (Sh.outpro), SH.Balance - (M.Qty * " & Deduct & "), getdate() " & _ "from stocks_History AS SH " & _ "INNER JOIN #Temp AS X " & _ "ON SH.ProCode = X.ProCode " & _ "AND SH.The_Date = X.The_Date " & _ "INNER JOIN Myset AS M " & _ "ON M.Procode = SH.Procode " & _ "inner JOIN Package AS P3 on P3.GCode = M.GCode and P3.Pckcode = '" & Pckcode & "' " & _ "drop table #temp " cn.Execute sql End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.