Control Source for testbox

  • Thread starter Red via AccessMonster.com
  • Start date
R

Red via AccessMonster.com

Good Day All,

I am wondering if it is possible to use a SQL Statement for the Control
Source of a text box? If so, how would I format it? I have tried to use the
SQL below but I get an error. Any help would be greatly appreciated.

VR,

Red

=Count FROM tblRecallInfo WHERE (((tblRecallInfo.Squadron)="48 MDSS") AND (
(tblRecallInfo.Category)="Contractor"))
 
F

fredg

Good Day All,

I am wondering if it is possible to use a SQL Statement for the Control
Source of a text box? If so, how would I format it? I have tried to use the
SQL below but I get an error. Any help would be greatly appreciated.

VR,

Red

=Count FROM tblRecallInfo WHERE (((tblRecallInfo.Squadron)="48 MDSS") AND (
(tblRecallInfo.Category)="Contractor"))

No, you cannot use a SQL statement as control source of an Access
control.

You can use DCount:
=DCount("*","tblRecallInfo","[Squadron] = '48 MDSS' AND [Category] =
'Contractor'")

The above assumes the values actually stored in [Squadron] and
[Cateory] are text values, not lookup numbers.
 
M

Marshall Barton

Red said:
I am wondering if it is possible to use a SQL Statement for the Control
Source of a text box? If so, how would I format it? I have tried to use the
SQL below but I get an error.

=Count FROM tblRecallInfo WHERE (((tblRecallInfo.Squadron)="48 MDSS") AND (
(tblRecallInfo.Category)="Contractor"))


Well, that's not an SQL statement, but No, you can not use
an SQL statement in a control source expression.

However, the Domain Aggregate functions can be used to do
what you want:

=DCount("*", "tblRecallInfo", "Squadron='48 MDSS' AND
Category='Contractor' ")
 
R

Red via AccessMonster.com

Thanks fredg,

It worked perfect. It is appreciated.

VR,

Red

Good Day All,
[quoted text clipped - 8 lines]
=Count FROM tblRecallInfo WHERE (((tblRecallInfo.Squadron)="48 MDSS") AND (
(tblRecallInfo.Category)="Contractor"))

No, you cannot use a SQL statement as control source of an Access
control.

You can use DCount:
=DCount("*","tblRecallInfo","[Squadron] = '48 MDSS' AND [Category] =
'Contractor'")

The above assumes the values actually stored in [Squadron] and
[Cateory] are text values, not lookup numbers.
 
R

Red via AccessMonster.com

Thanks Marshall,

The suggestion worked perfect. It is appreciated.

VR,

Red
 

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