DCount in Text box from a parameter query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I set up a report using a simple query as the control source. I used text
boxes with a DCount expression and it worked. I then added a parameter to
the query ie.[Enter Account Number], the query returns the correct
information but my Report text boxes (with DCount expressions) all say error?
 
=DCount("[Cal]","Query for Inspection Type Report","[Cal] = 'Dec'")
--
PRD


Steve Schapel said:
PD,

What are the DCount expressions?

--
Steve Schapel, Microsoft Access MVP
I set up a report using a simple query as the control source. I used text
boxes with a DCount expression and it worked. I then added a parameter to
the query ie.[Enter Account Number], the query returns the correct
information but my Report text boxes (with DCount expressions) all say error?
 
PD,

Thanks. Ok, is "Query for Inspection Type Report" the name of the query
that the report is based on? If so, it makes sense that Access can't
evaluate the DCount if there is an unevaluated Parameter.

One approach would be to forget the Parameter Query idea altogether, and
instead put an unbound terxtbox on a form which the user can use to
enter the Account Number. Then, in the query, replace the parameter
prompt with a reference to the textbox, using syntax such as...
[Forms]![NameOfForm]![NameOfTextbox]

In fact, I would recommmend doing this in any case.

Then, you could further simplify by changing the expression for your Dec
textbox to like this...
=-Sum([Cal]='Dec')
 
Ah ha!
Perfect and thank you very much.
--
PRD


Steve Schapel said:
PD,

Thanks. Ok, is "Query for Inspection Type Report" the name of the query
that the report is based on? If so, it makes sense that Access can't
evaluate the DCount if there is an unevaluated Parameter.

One approach would be to forget the Parameter Query idea altogether, and
instead put an unbound terxtbox on a form which the user can use to
enter the Account Number. Then, in the query, replace the parameter
prompt with a reference to the textbox, using syntax such as...
[Forms]![NameOfForm]![NameOfTextbox]

In fact, I would recommmend doing this in any case.

Then, you could further simplify by changing the expression for your Dec
textbox to like this...
=-Sum([Cal]='Dec')

--
Steve Schapel, Microsoft Access MVP
=DCount("[Cal]","Query for Inspection Type Report","[Cal] = 'Dec'")
 
Back
Top