referring to a totals query on a form


G

Guest

If I create a totals query, or one that uses the Top 1 value, or basically
any query that returns just one row, is it possible to refer to a field value
in it from a control on a form without using the domain aggregate functions?
It seems like there must be an easier way to get that value than using
dlookup. But just pointing to the field from a control produces a #Name error.

Thanks in advance.
 
Ad

Advertisements

M

Marshall Barton

bicyclops said:
If I create a totals query, or one that uses the Top 1 value, or basically
any query that returns just one row, is it possible to refer to a field value
in it from a control on a form without using the domain aggregate functions?
It seems like there must be an easier way to get that value than using
dlookup. But just pointing to the field from a control produces a #Name error.

Well, there are other ways to do that, but a DLookup to your
query is the easiest way to get a single field's value.

If your one row query returns multiple fields, then you
would get better perfomance by using a VBA procedure to open
a recordset on the query and then copying the field values
to their related text boxes.
 
Ad

Advertisements

G

Guest

Another option is to add that query to the recordsource of the form, without
linking the table to the query, then add the field, then you can bound the
field in the form to this field. The problem is that you wont be able to
update the data.

So I would keep using the dlookup without criteria, if there is only one
record
=dlookup("FieldName","TableName")
 

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

Similar Threads

Refer to Total in query 1
Totals Query 1
totals query 1
Totals Query 10
Totals Query 2
Totals Query 3
Query Totals 3
Query Totals 1

Top