Attach a query to a text box

J

Jeffh

I would like help attaching a query to a text box. Below is examples of my
tables and the query I would like to attach. The query works fine, I just
would like to attach it to a text box. Any help would be appreciated.

I have two tables, Class and CostTable

The Class table has just a primary key and a text field called Class. The
CostTable has a primary key called CostID and fields for Class,
SizeBeginRange, SizeEndRange and Cost. I set up a relationship between Class
in the Class table and Class in the CostTable.

I am running the following query which gives me the correct result.

SELECT [Enter Sq Ft]*[Cost] AS [Total Cost], CostTable.CLASS,
CostTable.SizeBeginRange, CostTable.SizeEndRange FROM CostTable WHERE
(((CostTable.CLASS)=[Enter Class]) AND ((CostTable.SizeBeginRange)<=[Enter Sq
ft]) AND ((CostTable.SizeEndRange)>=[Enter Sq ft]));

I would like somehow to tie this query to a user form. I would like one
text box where the user enters the square feet and a second one where they
can enter the class. The second one could even be a combo box since the
values will never change and it may actually be easier to choose from a list
of existing options. Lastly, I would like the results to be displayed in
another text box. Any suggestions on setting this up would be appreciated. I
have tried several ways and always get the same result.... #NAME? in the
text box for the result. Not exactly sure what I am doing wrong here...
 
P

pietlinden

Jeffh said:
I would like help attaching a query to a text box. Below is examples of my
tables and the query I would like to attach. The query works fine, I just
would like to attach it to a text box. Any help would be appreciated.

I have two tables, Class and CostTable

The Class table has just a primary key and a text field called Class. The
CostTable has a primary key called CostID and fields for Class,
SizeBeginRange, SizeEndRange and Cost. I set up a relationship between Class
in the Class table and Class in the CostTable.

I am running the following query which gives me the correct result.

SELECT [Enter Sq Ft]*[Cost] AS [Total Cost], CostTable.CLASS,
CostTable.SizeBeginRange, CostTable.SizeEndRange FROM CostTable WHERE
(((CostTable.CLASS)=[Enter Class]) AND ((CostTable.SizeBeginRange)<=[Enter Sq
ft]) AND ((CostTable.SizeEndRange)>=[Enter Sq ft]));

Just change the filter to
<=Forms![MyFormName]![NameOfTextBoxControl] AND >=
Forms![MyFormName]![NameOfTextBoxControl]

Lastly, I would like the results to be displayed in
another text box.

Sure they're going to fit? If it's a textbox, it's a PITA. Better off
using a subform and setting the rowsource in the click event of a
button or something.
 

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