Text box

J

Jeffery

I would like to run a query from an unbound text box in a form to show a
value. When the form is open instead of a value I get a #name? display.

The control source for the text box is as follows:

=IIf([qryIncidentsCountClosed]![Count] Is
Null,"0",[qryIncidentsCountClosed]![Count]).

The underlying query (qryIncidentsCountClosed) is:

SELECT Count(tblIncident.IncidentNum) AS [Count]
FROM tblIncident
WHERE (((tblIncident.Critical)=-1) AND ((tblIncident.DateClosed) Is Not Null
And (tblIncident.DateClosed)>(Date()-365)) AND ((tblIncident.[Customer
Number])=[Forms]![Customers]![Customer Number]));

Any suggestions on how to get this to work?

I would like to display a count of open and closed incidents for the
customer when the form is open. The above stuff is for the count of closed
incidents.

Thanks
Jeff G
 
K

Ken Snell [MVP]

You cannot "reference" a query in a control source the way you're trying to
do.

Use a DCount function to get the result instead:

=DCount("IncidentNum", "qryIncidentsCountClosed", "Critical=-1 AND
DateClosed Is Not Null And DateClosed>(Date()-365) AND [Customer Number]=" &
[Forms]![Customers]![Customer Number])
 
J

Jeffery

Ken/Graham-
Thanks for the help. I'll give it a try!
-----Original Message-----
You cannot "reference" a query in a control source the way you're trying to
do.

Use a DCount function to get the result instead:

=DCount
("IncidentNum", "qryIncidentsCountClosed", "Critical=-1
AND
DateClosed Is Not Null And DateClosed>(Date()-365) AND [Customer Number]=" &
[Forms]![Customers]![Customer Number])

--

Ken Snell
<MS ACCESS MVP>



news:5897F37B-0788-4EB3-A394-
(e-mail address removed)...
I would like to run a query from an unbound text box in a form to show a
value. When the form is open instead of a value I get a #name? display.

The control source for the text box is as follows:

=IIf([qryIncidentsCountClosed]![Count] Is
Null,"0",[qryIncidentsCountClosed]![Count]).

The underlying query (qryIncidentsCountClosed) is:

SELECT Count(tblIncident.IncidentNum) AS [Count]
FROM tblIncident
WHERE (((tblIncident.Critical)=-1) AND
((tblIncident.DateClosed) Is Not
Null
And (tblIncident.DateClosed)>(Date()-365)) AND ((tblIncident.[Customer
Number])=[Forms]![Customers]![Customer Number]));

Any suggestions on how to get this to work?

I would like to display a count of open and closed incidents for the
customer when the form is open. The above stuff is for the count of closed
incidents.

Thanks
Jeff G


.
 

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