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

command , etc.
write insert commond here

Catch ex As

If ex.Message.
IndexOf("Company_ID") Then
("Duplicate data
entry found")
unexpected error
occured: " &
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).

thank you for helping me in this

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.