Solved

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

Posted on 2014-09-16
3
240 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
3 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 100 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 57

Assisted Solution

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

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

Jim.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 300 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now