dcount

C

cbTear

I have a field in a report that uses a query called
"qryMPV_DateRange_SelectNurses_FromForm" in the dcount function.
I am using the dcount function in may different reports; with different
query names. Is there a way to tell dcount to use the query that is the
record source of the report? or do I have to repeat this query name in the
dcount function everytime it is used?

Text box Field example
=DCount("[II6]","qryMPV_DateRange_SelectNurses_FromForm","[II6]>0 and
[II6]<3 ")

Thanks for any ideas, CB
 
F

fredg

I have a field in a report that uses a query called
"qryMPV_DateRange_SelectNurses_FromForm" in the dcount function.
I am using the dcount function in may different reports; with different
query names. Is there a way to tell dcount to use the query that is the
record source of the report? or do I have to repeat this query name in the
dcount function everytime it is used?

Text box Field example
=DCount("[II6]","qryMPV_DateRange_SelectNurses_FromForm","[II6]>0 and
[II6]<3 ")

Thanks for any ideas, CB


As the control source of an unbound control?
No.

Using code? yes.
[SomeControl] =DCount("[II6]",Me.RecordSource,"[II6]>0 and [II6]<3 ")
 
K

Klatuu

Interesting idea. I have never tried that, but if you want to test it, here
is the syntax to return the name of the query:
Application.Reports("MyReportNameHere").RecordSource

As to technique, I would suggest you declare a module level variable to hold
the value and set it in the Open event.

At the top of the report's module:
Dim strQry as String

In the Open Event:

strQry = Application.Reports("MyReportNameHere").RecordSource
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top