Actually I'm doing a project to maintain the company info, here i wanted to write a code to check whether the company id already exists or not. that is if the id 123 is already present in the access database then it shuld show the msg that it already exist. Please can any one help me in this.

make your company id primery key in database.
Now add the follwing code to your save button

Try
'Initialize
factory,
connectionstring,
adapter,
command , etc.
doInsert()
write insert commond here

Catch ex As
Exception

If ex.Message.
IndexOf("Company_ID") Then
MsgBox
("Duplicate data
entry found")
Else
MsgBox("An
unexpected error
occured: " &
ex.Message)
End If
End Try

Do a query to select the record with that ID. If it returns a record then you know that it exists.

Dim myID As String = "123"
query = "SELECT * FROM myTable WHERE company_ID = '" & myID & "'"

or even

query = "SELECT COUNT(*) FROM myTable WHERE company_ID = '" & myID & "'"

To return only the number of records found. How you execute the query depends on the method used to access the database (SQL, ADO, OLEDB).

This question has already been answered. Start a new discussion instead.