Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

domain function question

Posted on 2014-02-19
4
Medium Priority
?
293 Views
Last Modified: 2014-02-20
Hi all,

I need to know what is the most efficient way to get the following in vba

count of distinct dates for certain criteria.

for example, how many distinct dates are scheduled for this week.

two schedule records for Sunday are considered 1, while Sun, Mon, Tue are counted as 3.

I know I can do it in a saved distinct query and use DCount of that query, however wonder if that is the most efficient way of accomplishing it, as i am dealing with a very large table.
0
Comment
Question by:bfuchs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39871944
start with this

Select Count(A.Dates) as CountOfSchedules
from
(select TableX.Dates From TableX
  Group By TableX.Dates
) As A
0
 
LVL 4

Author Comment

by:bfuchs
ID: 39871950
hi,
and how do i get this results into a variable?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39871971
save the above query as QCount

open it as recordset

dim rs as dao.recordset, xCount as integer
set rs=currentdb.openrecordset("QCount")

xCount=rs!CountOfSchedules
0
 
LVL 4

Author Closing Comment

by:bfuchs
ID: 39874778
Thanks allot Ray, that worked, however just wonder if the following approach would perform faster?
create a SQL function that accepts a int variable and returns a int, then have this function being called from the app.
p.s. its a ms access front end application linked to SQL Server back end.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

721 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