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

  • Thread starter Thread starter David Burkhart
  • Start date Start date
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
 
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.
 
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
'====================================================
 
It is a saved query that returns a single row. Your guidance to use
DLookup works perfectly. Thank You very Much!

drb
 
Back
Top