Solved

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

Posted on 2014-09-16
3
242 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

920 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

16 Experts available now in Live!

Get 1:1 Help Now