?
Solved

checking to see if a query/table in Access has any rows

Posted on 2014-09-16
3
Medium Priority
?
254 Views
Last Modified: 2014-09-16
Experts,

I have a query in Microsoft Access that is later used to export to Excel.  Is there a way I can tell if rows were returned?  If no rows are returned, I do not want to export the table.
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 400 total points
ID: 40325247
Only if you are using VBA and can use the Recordset.RecordCount property.

If you are not using VBA, then you could build a form to show you how many records there are, and have a button linking to the Export to Excel code, and you can manually see if there are zero records or not.
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 400 total points
ID: 40325278
Simplest way:

  If DCount("*","<queryname>") >1 then
     ' Do the Export
 End If

Jim.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1200 total points
ID: 40325279
you can use

if dcount("*","queryName")>0 then
  'export to excel
  else
   msgbox "No records to export
end if
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question