Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2004, 09:33 PM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display 0 when no records found in a query

Hello all. I am running a query dependent on 4 queries which calculates turnover by counting the number of hires, the number of terms, suming the counts and dividing term/hires. For some months there are no terms and the query that counts the number of terms returns nothing (just the grey field names) How do I get this query to return zero for these instances so when I run the last query, I get 0%? I tried to use the Nz function but I am not using it correctly. Here is the count portion of my code:

strSQL = "SELECT Count(tbl_Employee.enumberID) AS CountofenumberID, tbl_Market .marketID FROM ......;

Going forward, I append the results from the final query to a table and for the months where there is no turnover the hire information does not get appended. I need these months to appear since I append the number of terms, hires, and the corresponding market and date. For example:

Terms Hires Market Month
12 36 AR14 Jun-04
0 15 AR14 Jul-04


Currently, the second record does not appear since the query returns nothing or Null.

Thanks for your help!!!

 
Old December 2nd, 2004, 03:39 PM
Authorized User
 
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

The only certain way I know how to do this is to turn your query into a recordset e.g.

Dim rst_data as recordset
Dim dbl_answer as long
.....

set rst_data = currentdb.openrecordset("sqlstr.....")
dbl_answer = rst_data.recordcount

....

set rst_data = nothing

and then pass dbl_answer into your final table. If there are no records, dbl_answer will have the value 0, just as, I think, you wanted. This is DAO, but works equally well in any version of Access if you have the references selected

Cheers







Similar Threads
Thread Thread Starter Forum Replies Last Post
display Records in ComboBox therese C# 2005 4 July 26th, 2008 05:28 AM
Repeater Control: No Records Found jumpseatnews ASP.NET 2.0 Basics 9 August 29th, 2007 04:19 PM
Record not found Display Dept name mateenmohd Classic ASP Basics 0 May 15th, 2005 12:26 AM
Query to display non matching records. AJ Access VBA 1 April 7th, 2005 05:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.