Re: Finding the Count in an Update Query

Tech-Archive recommends: Fix windows errors by optimizing your registry



Dirk,
How do I pass through the parameter from my form to the query when I kick it
off using this method.

Thanks

--
SC from Lubbock, Texas


"Dirk Goldgar" wrote:

"SC in Texas" <SCinTexas@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E65B9CA9-3A79-438E-AE94-A3C2A4229E80@xxxxxxxxxxxxxxxx
I have an update query that should only have 1 record to update or no
records
to update when kicked off by a command button in my form. How can I find
the
count of records to be updated to create my own message box, if the count
is
zero instead of using the warning message box that Access brings up
showing
the number of rows to be updated?
Option 2 How can I edit the message in that message box?
Thanks in advance.


If you execute the query via the DAO Execute method, rather than RunSQL or
OpenQuery, then you can examine the database's RecordsAffected property.
Thus:

With CurrentDb
.Execute "YourUpdateQuery", dbFailOnError
If .RecordsAffected = 0 Then
MsgBox "No records were updated."
Else
MsgBox "You just updated " & .RecordsAffected & " record(s)."
End If
End With


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.


Quantcast