By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,072 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,072 IT Pros & Developers. It's quick & easy.

How to Trigger "No Records Found" When There is No Records in .accde/.accdr?

100+
P: 131
Hi all once again!!!!
I have a database in .accde/.accdr format. The database has been designed using many relational tables.
I set a form for deleting some records or all database.
The problem is when you delete the records with action query it pop-up a message saying "you about to delete zero rows (0s)from-specified table" ten times for 5-relational tables. It is very annoying!
I know how to get read of this message and display a customer message as follows
Expand|Select|Wrap|Line Numbers
  1. Function messagebox()
  2. Dim Msg, Style, Title, Help, Ctxt, Response, MyString
  3. Msg = "Do you for Real want to delete This Records ?"    ' Define message.
  4. Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
  5. Title = "Delete confirmations"    ' Define title.
  6.  
  7. Response = MsgBox(Msg, Style, Title, Help, Ctxt)
  8. If Response = vbYes Then    ' User chose Yes.
  9. DoCmd.OpenQuery "DeleteMytableName", acViewNormal
  10. DoCmd.RunMacro "Confirmation"
  11. Else    ' User chose No.
  12. Doc.RunMacro "Cancel"
  13. End If
  14. End Function
  15.  
  16.  
It runs perfectly with DoCmd.RunMacro "Confirmation" as messagebox macro for confirmation and
Doc.RunMacro "Cancel" for cancellation.
The problem with this, once you select the record to delete, it keep deleting without giving any indication that there is no records in the database.
How to set the code above to search for presence/absence of records first before attempting to delete empty table regarding the following criteria???
1. If no records, then NO RECORDS FOUND message should be displayed without taking any further actions
2. If there are records on the related table then it should delete it with warnings as explained above

Happy X-Mas and New Year!!!
Dec 20 '11 #1

✓ answered by NeoPa

I suggest you open the record source (Table or Query) you want to delete from using a DAO.Recordset object and check for EOF. If EOF is already true then there are no records.

If the record source is either a table or a QueryDef (Not SQL), then you can use DCount() of it to determine if there are any records or not.

Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,709
I suggest you open the record source (Table or Query) you want to delete from using a DAO.Recordset object and check for EOF. If EOF is already true then there are no records.

If the record source is either a table or a QueryDef (Not SQL), then you can use DCount() of it to determine if there are any records or not.
Dec 21 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.