How return count from SQL Query to a field data source at EOF

D

David Burkhart

I have developed an SQL Query that does a complex search through my
database and returns the correct single number as the answer when I run
it stand alone, but I have not been able to figure out how to get a
textbox to accept the field from the Query. I am having a brain freeze
and would appreciate any help I can get.

drb
 
M

Marshall Barton

David said:
I have developed an SQL Query that does a complex search through my
database and returns the correct single number as the answer when I run
it stand alone, but I have not been able to figure out how to get a
textbox to accept the field from the Query. I am having a brain freeze
and would appreciate any help I can get.


Either use DLookup to get the value:
=DLookup("thefield", "thequery")

or use code to open a recordset on the query and copy the
field from the recordset to the text box"

With CurrentDb.OpenRecordset("thequery")
Me.thetextbox = !thefield
End With

Both of those do the same amount of work so unless there is
another reason to use the recordset, you might as well use
the simpler DLookup.
 
J

John Spencer

If your query is a saved query and is returning just one row, you could
use the DLookup function as the control's source.

=DLookup("NameOfField","NameOfQuery")

If the query varies depending on which record is the current source for
the current detail then you need to post more details on the query and
your report.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
D

David Burkhart

It is a saved query that returns a single row. Your guidance to use
DLookup works perfectly. Thank You very Much!

drb
 

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