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

If no records to append then message box

Status
Not open for further replies.

BHScripter

Technical User
Aug 26, 2002
159
0
0
US
Hi:

I have an append query which is set so that data which has already been imported once is filtered out of any subsequent appends. It is possible that no records would be appended.

How could I code a message box that is triggered if no records are appended?

Thanks,
Brianna
 
there is a RecordsAffected property - of the QueryDef object, i believe - that can give you a count of how many records will be added. you could also access the Count property of the table being appended to, and have your code look at it again after running the query to determine whether it has changed. if not call the MsgBox function.

- may seeds of dreams fall from my hands
and by yours be pressed into the ground
 
Thanks, I will look at both of those and let you know how it goes :)
 
i'm assuming you launch the append query with a button on a form.

if you make a select query the exact same as the append query (except it SELECT instead of APPEND), then count the number of records in that query. if there are none, make a message in the button's OnClick event:

if dcount("ID","SelectQueryName") = 0 then
msgbox "There are no records appended!",vbOkOnly,"STATUS"
exit sub
else
--run the query--
end if
 
Hi Ginger:
What is the "ID" representing in the Dcount function??
Thanks,
 
a field in your table or query.
you can look up dcount in HELP or a text book.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top