Using a Query to Populate Form Control

K

Ken Hudson

I am using Access 2007.

I have a form that gets is data from a table.
I have a control on that form that I want to get its value from a query
called qryTest:

SELECT Sum(tblWipIn.curWipCost) AS XXXTtl
FROM (tblPOs INNER JOIN tblWipDocIDs ON tblPOs.pkPoID = tblWipDocIDs.fkPoID)
INNER JOIN tblWipIn ON tblWipDocIDs.pkWipID = tblWipIn.fkWipID
WHERE (((tblPOs.pkPoID)=[Forms]![frmWipPosub]![pkPOID]));

The form control is named “Unused.†I used the expression builder for the
control source and got:

=nz([qryTest]![xxxTtl],0)

When I open the form, I get #Name? in the object.

In my web searches I found a string in which the author stated that you can
not use a query to populate a control unless it is bound to the form. I
should use Dsum or write a function.

Can someone validate that the query error can not be fixed?
 
L

Linq Adams via AccessMonster.com

You cannot use a SELECT query to populate a control on a form. The usual
approach is to use the DLookUp() function, which can be run against either a
table or a query. Go to Access help and enter DLookup as the search term for
details, and come back here if you need help.
 

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