Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access returns update confirmation?

Status
Not open for further replies.

PeggyC

Programmer
Apr 4, 2002
15
US
Does anyone know if when I send an update command to an Access database, does Access send any information back to VB to confirm that it has updated the table?

 
It depends on whether you're using DAO or ADO. With DAO, use the dbFailOnError option and the call will generate a run-time error if, for example, the query can't execute because it would cause a key violation.

With ADO, the call will generate a runtime error if not successful, also you can check the 'RecordsAffected' parameter which is the 2nd parameter for the Execute method.

'DAO style:
Dim db As DAO.Database
'(set db by opening a database)
db.Execute "UPDATE TABLE1 SET NAME='AAA'", dbFailOnError

'OR -- ADO style:
Dim cn As ADODB.Connection
Dim lngRecs As Long
'(set cn by opening a database)
cn.Execute "UPDATE TABLE1 SET NAME='AAA'", lngRecs, adCmdText
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top