Greetings,
novice here
Access database with a table that has the field RecordID as autonumber.
I need to identify and pass the record number of the highest record in this table, to a text field. This occurs immediately after the record has been written. My code is below. I am getting and IndexOutOfRangeException on the bolded line. Any suggestions would be most appreciated.
Dim strSQL As String = "SELECT MAX([One Time MX OMP tbl].RecordID) FROM [One Time MX OMP tbl]"
Dim cmd2 As New OleDbCommand(strSQL, New OleDbConnection(strConn))
cmd2.Connection.Open()
Dim dataReader As OleDbDataReader = cmd2.ExecuteReader
dataReader.Read()
txtRecordID.Text = dataReader("RecordID").ToString
cmd2.Connection.Close()
cmd2.Connection.Dispose()
novice here
Access database with a table that has the field RecordID as autonumber.
I need to identify and pass the record number of the highest record in this table, to a text field. This occurs immediately after the record has been written. My code is below. I am getting and IndexOutOfRangeException on the bolded line. Any suggestions would be most appreciated.
Dim strSQL As String = "SELECT MAX([One Time MX OMP tbl].RecordID) FROM [One Time MX OMP tbl]"
Dim cmd2 As New OleDbCommand(strSQL, New OleDbConnection(strConn))
cmd2.Connection.Open()
Dim dataReader As OleDbDataReader = cmd2.ExecuteReader
dataReader.Read()
txtRecordID.Text = dataReader("RecordID").ToString
cmd2.Connection.Close()
cmd2.Connection.Dispose()