Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

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

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
morinia
Asked:
morinia
3 Solutions
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
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
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Simplest way:

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

Jim.
0
 
Rey Obrero (Capricorn1)Commented:
you can use

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now