Use results of a Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have the results of Query1 appear in txtBox1 when I click
submit.

Not sure how to do this. By design, my query will only return 1 row. I can
execute the query in a docmd.openquery statement. I also have the SQL string
from the query. How can I move the integer result of the query to txtBox1 on
my form?

Humbly,

David
 
I would like to have the results of Query1 appear in txtBox1 when I click
submit.

Not sure how to do this. By design, my query will only return 1 row. I can
execute the query in a docmd.openquery statement. I also have the SQL string
from the query. How can I move the integer result of the query to txtBox1 on
my form?

Humbly,

David

As long as only 1 record is returned, use:

=DLookUp("[ColumnNameInQuery]","Query1")

You do not need to actually run the query, as long as it is a saved
query (i.e. in the Queries list).
 
David,

What is the Record Source of the form? Do you mean this is a bound
form, bound that is to a different table or query than the Query1 we are
talking about? If not, just make your form based directly on Query1 as
its recordsource, and then you can put the integer field from your query
as the Control Source of txtBox1. If the form is already bound, you
will be able to include Query1 into the query that the form is currently
based on, and once again show the integer value from the query directly
onto the form.
 
Back
Top