MsgBox How Meny records updated

  • Thread starter Thread starter zionsaal
  • Start date Start date
Z

zionsaal

how can I create A msg box should show how many records the run sql
cmd just updated I have the set warnings off
 
Hi,


something like
"dim RA as Long"
"currentproject.Connection.Execute "Command String", RA"?

Can you show us the code?
 
Try:
Private Sub Command3_Click()
With CurrentDB
.Execute "update master set tag = true where tag = false"
MsgBox "Total records affected by this operation is [" & .RecordsAffected
& "]"
End With
End Sub

Look into the RecordsAffected Property of a DAO Recordset.
[quoted text clipped - 7 lines]

the code:

Private Sub Command3_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "update master set tag = true where tag = false"
DoCmd.SetWarnings True
 
the code:

Private Sub Command3_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "update master set tag = true where tag = false"
DoCmd.SetWarnings True

Change it to:

Private Sub Command3_Click()
Dim db As DAO.Database
Dim qd As DAO.Querydef
Dim strSQL As String
On Error GoTo Proc_Error
Set db = CurrentDb
strSQL = "UPDATE Master SET Tag = True WHERE Tag = False;"
Set qd = db.CreateQuerydef("", strSQL)
qd.Execute dbFailOnError
MsgBox qd.RecordsAffected
Set qd = Nothing
Proc_Exit: Exit Sub
Proc_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Proc_Exit
End Sub

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top