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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count updated records 1

Status
Not open for further replies.

KUZZ

Technical User
Aug 13, 2002
254
GB
I am running a SQL statement behind a form. Instead of all warning messages, e.g. you will now update x records, are you sure you want to go ahead...bla bla, I would only like to see a message box with "X records updated" or "X records were locked, could not update". I can start by
docmd.setwarnings =false, but what is the syntax to follow?
 
KUZZ,

You would need to use a domain function such as DCOUNT that would give you the count of records based on the same criteria the query would use.

For example DCOUNT("[LastName]","Customers","[LastName]=Smith")

Would give you a count of all customers who had the last name Smith.


HTH,


Steve
 
If you use an ADO connection object you can get this:


Dim lngRecordsAffected
Dim strSQL
Dim CNN as Adodb.Connection

strSQL = "update salary set mine=200000"

Set CNN = CurrentProject.Connection
CNN.Execute strSQL,lngRecordsAffected,adCmdText

Msgbox str$(lngRecordsAffected) & " records updated"

Turn your headache into my project!
Jeffrey R. Roberts
Insight Data Consulting
Access and SQL Server Development
 
If you use the Execute method on a DAO QueryDef, you can then read its RecordsAffected property.
 
That's good--so you can use existing query objects (can be done in ADO but much more coding). DAO wins again.

Turn your headache into my project!
Jeffrey R. Roberts
Insight Data Consulting
Access and SQL Server Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top