We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Increment Field Value

Hi All, I have 2 tables, TradeIn and ParaTable Both the tables have Fields ---TradeInNo and DivCd IF the TradeIn No is 100 the first time for a particular DivCd, on successive attempts it should be incremented. i.e., 101, 102, 103...etc DivCd is used to identify the various divisions namely, A, B, C, D according to which the TradeInNo is classified. That is for Division A tradeIn NO starts at 1000, B - 2000 etc. The below code gets me the first TradeInNo directly as available in Paratable: Code: ---------- Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click txtDate.Text = Date.Today Dim con As String = Application("conn") Dim SqlCon As New SqlConnection(con) Dim str As String str = ("Select TradeInNo from ParaTable where DivCd=''" & Application("DiviID") & "''") Dim cmd As SqlCommand = New SqlCommand(str, SqlCon) SqlCon.Open() Dim dr As SqlDataReader dr = cmd.ExecuteReader() While dr.Read txtTradeInNo.Text = dr.Item("TradeInNo").ToString End While SqlCon.Close() End Sub ----------------------------------------------- I want it that the last Trade In No from TradeInNo Table be checked and then this value should be incremented to give the new value for the corresponding division. Kindly help me to sort this out. Thanks and Regards, lis Db is in Sql

Loader.
Live Chat Icon For mobile
Up arrow icon