database - field[counterx3 - Id(text)Primary Key]

my code works really well before but when i changes and add codes in the others forms i got error in updating the value in my database, here's my code for update

 sql = "update counterx3 set ID='" & Val(acsdr!ID) + 1 & "'"
        Dim ccmd = New OleDb.OleDbCommand(sql, con)
        ccmd.ExecuteNonQuery()
        ccmd.Dispose

and here's the other one

    Public Sub ordernumber()
        sql = "select * from counterx3"
        Dim cmd = New OleDb.OleDbCommand(sql, con)
        acsdr = cmd.ExecuteReader()
        If acsdr.Read Then
            lblordernum.Text = "ORDER NUMBER: " & acsdr!ID
        End If
        Me.Refresh()
    End Sub

my error is in the update, it says "No data exists for the row/column."
Please help, i'm working on this error since last night :( , but i really can't figure out what the reason of the error

Can you capture the error in debug mode so we can see which line produce the error.

Here:

Here: Untitled.png

Try to verify if the variables that host data to be updated to a database do return or hold something, mean check if they are not null, because it seems as if one or more variable has no data within it, its null.

it's not null, actually when i save a new record in database in different field the counterx3-id need to be increment

Try using 'For' statement to increment starting from 0 upwards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.