Custom MsgBox to display rows appended

jhitchzurp7

New member
Local time
Yesterday, 20:46
Joined
Nov 2, 2012
Messages
3
I have some buttons in my db which run various append and update queries and I would like to have some custom Msgboxes display the number of rows updated/appended each time they are run. Any ideas? I believe I need to use dcount("*","NameOfQuery") before the query is ran, then call that number into the msgbox but I am not sure how the vba code will look. Any help would be much appreciated
 
Msgbox(dcount("*","NameofQuery") & " records were updated!")

---Correction-----

You cannot use Dcount against an append query. Just tested this - sorry. Try creating a copy of your append query and convert it to a SELECT query and then do a dcount against that query.
 
Last edited:
A better way is to use this:

Code:
With CurrentDb
   .Execute "QueryNameHere", dbFailOnError
   MsgBox "There were " & .RecordsAffected & " records appended."
End With
 
I added this on the Navigation form load event and it comes back with Run-time error 3061. What am I doing wrong?
 
I added this on the Navigation form load event and it comes back with Run-time error 3061. What am I doing wrong?

If you have parameters in the query, you have to supply them:
http://msdn.microsoft.com/en-us/library/aa984789(v=VS.71).aspx

I find that recreating the query in VBA is easiest for me.

Dim strSQL As String

strSQL = "Select * From tableNameHere Where FieldName=" & Chr(34) & Me.TextBoxNamHere & Chr(34) & " And Field2Name=#" & Me.TextBoxWithDateInIt & "#"

And then execute it.
 

Users who are viewing this thread

Back
Top Bottom