DoCmd.OpenQuery return type required

  • Thread starter Thread starter vikash.verma
  • Start date Start date
V

vikash.verma

Hi All,
I have written a query in my QUERY with the name as "QueryCount".
Now i am calling the query in VBA by using the DoCmd.OpenQuery like this

DoCmd.OpenQuery "QueryCount", acViewNormal, acReadOnly

Inside QueryCount my query is like this ----- SELECT
Count(DelMastTemp.CustomerID) AS NumCount FROM DelMastTemp;


I get a value 20 ie NumCount =20, when i run my Application.But now i want
to display the value from the Application.I want to display the value from
my VB Code .But i am not getting it.
I tried assigning string name/varient/integer Type to the "DoCmd.OpenQuery
" but it gives an ERROR.

How to get the NumCount value in my Application is becoming a problem for
me.
If my approach is wrong then let me know or if there is any other way to
handle it.??

I am expecting mails from you all.

Hope to hear from you all

Regards,
Vikash
 
Dim intCustCount as Integer
intCustCount = DCount("CustomerID", "DelMastTemp")
You now have the variable with the count.
 
Hi
I have to get the NumCount value from the Query

Inside QueryCount SELECT Count(DelMastTemp.CustomerID) AS NumCount FROM
DelMastTemp WHERE (((DelMastTemp.CustomerID)='7010') AND
(DelMastTemp.StartDate)= #8/22/2003#));

I got values by using DCount but it also displayes Count = 1 even if there
are no records present in the Ms Access DBase because it shows at least 1
Row with NumCount =0

So i want to display the NumCount value OR the Count as 0 any thing which
will fetch me .
I am trying from my side..

Hope to hear from you all

Thanks
Vikash
 
I can't imagine that DCount() would return a number greater than 0 if there
are no records in the "domain".

Try
Dim intCustCount as Integer
intCustCount = DLookup("NumCount", "QueryCount")
 
Back
Top