can anyone help me regarding this??..i have here the code to get the new last record after deleting the last record...but i encountered an error saying... "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll
Additional information: locid, make sure data column names are correct, ,make sure the index is not a negative number, make sure that the maximum index on the list is less than the list size"....

access = "select MAX(locid) from tbl_location"
            cmd = New OleDbCommand(access, con)

            dtr = cmd.ExecuteReader()
            If dtr.HasRows() Then


                txt_locid.Text = dtr("locid").ToString
                txt_locname.Text = dtr("locname").ToString
                txt_locadd.Text = dtr("locadd").ToString
            End If

your query will not return the columns name "locid,locname,locadd", it will return 1 column as you put in the query

your only column is MAX(locid), and since you didnot specify the a name by using MAX(locid) as FieldName, its hard to tell what will be the column name.

You are getting 1 column contains Max(locid), so to get it correctly

xt_locid.Text = dtr(0).ToString

and remove the other two since they don't exist.

thanks samir ibrahim....i got it... :)