Text Box filtering

A

awach

I am trying to have a subform that only shows certain values. The control
source for the form is a query, [Specific Models Subform]:

Part Number Class Allocation

I have a comboBox that is on the subform that allows just the choices for a
certain class to be available by using a row source:

SELECT Form1.Name FROM Form1 WHERE Form1.Class="Cash";

I would like a text box to have the same property. I have the control
source as:

SELECT Allocation FROM [Qry1] WHERE Class="Cash";

but it's not working. What am I doing wrong? Thanks
 
R

Rick Brandt

awach said:
I am trying to have a subform that only shows certain values. The control
source for the form is a query, [Specific Models Subform]:

Part Number Class Allocation

I have a comboBox that is on the subform that allows just the choices for a
certain class to be available by using a row source:

SELECT Form1.Name FROM Form1 WHERE Form1.Class="Cash";

I would like a text box to have the same property. I have the control
source as:

SELECT Allocation FROM [Qry1] WHERE Class="Cash";

but it's not working. What am I doing wrong? Thanks

Since TextBoxes don't have a RowSource property I must assume you placed that in
the ControlSource property. If so you cannot do that. A ControlSource cannot
evaluate a SQL statement.

You could use the DLookup() function though...

=DLookup("Allocation", "Qry1", "Class = 'Cash'")

That will retrieve the value of the Allocation field from the first arbitrary
row that matches the criteria. The control will not be editable of course.
 
A

awach

Could I filter the form using the filter property to ((Form1.Class="Cash"))?
Would that do the same thing?




Rick Brandt said:
awach said:
I am trying to have a subform that only shows certain values. The control
source for the form is a query, [Specific Models Subform]:

Part Number Class Allocation

I have a comboBox that is on the subform that allows just the choices for a
certain class to be available by using a row source:

SELECT Form1.Name FROM Form1 WHERE Form1.Class="Cash";

I would like a text box to have the same property. I have the control
source as:

SELECT Allocation FROM [Qry1] WHERE Class="Cash";

but it's not working. What am I doing wrong? Thanks

Since TextBoxes don't have a RowSource property I must assume you placed that in
the ControlSource property. If so you cannot do that. A ControlSource cannot
evaluate a SQL statement.

You could use the DLookup() function though...

=DLookup("Allocation", "Qry1", "Class = 'Cash'")

That will retrieve the value of the Allocation field from the first arbitrary
row that matches the criteria. The control will not be editable of course.
 
Top