How to Use a Query Result in a Microsoft Access Text Box
Question details
The user wants to display the result of an independent query inside a text box on a Microsoft Access report or form.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Setting a text box's control source to an existing query to display a specific amount or result on a report.
- Observed behavior
- Using the entire query as the text box's control source produces an error because a text box can only bind to a single field or expression, not a complete query object.
Determine whether the query you are referencing returns a single specific value or multiple rows, as this dictates whether you should use a single text box or a subform.
Use the DLookup Function for a Single Value
If your query is designed to return a single specific value, you can use the DLookup function in the text box's Control Source to extract that value without triggering an error.
A standard text box requires a single value to display. Because a query inherently returns a dataset (which could contain multiple rows and columns), Access cannot bind an entire query directly to a text box. The DLookup function resolves this by pinpointing exactly one field from one record.
Right-click your form or report in the Navigation Pane and select 'Design View'.
Select the text box you want to populate, right-click it, and choose 'Properties' to open the Property Sheet.
In the Data tab of the Property Sheet, click into the 'Control Source' property and type your DLookup expression. For example: =DLookup("YourFieldName", "YourQueryName", "ID = 1")
Save your changes and switch to Form View or Report View to verify that the single query result now displays correctly in the text box.

Insert a Subform to Display Multiple Query Rows
If your query returns multiple records or multiple fields that need to be displayed simultaneously, a single text box will not work. A subform is the correct control to use.
Need a Free Alternative for Your Office Documents?
While WPS Office does not include a database management tool like Microsoft Access, it offers a powerful, free, and fully compatible suite for handling all your word processing, spreadsheets, and presentation needs.
- 1. Download the Installer: Visit the WPS Office official website and download the free installer for your operating system.
- 2. Install WPS Office: Run the setup file and follow the on-screen instructions to complete the fast installation process.
- 3. Open Your Office Files: Launch WPS Office and directly open any of your existing DOCX, XLSX, or PPTX files to continue working immediately.

Frequently Asked Questions
Why do I get an error when setting an Access query as a text box control source?
A text box is designed to hold only a single piece of data (one value). A query is a dataset that can potentially return multiple columns and rows. Because Access cannot automatically condense a full dataset into a single string, it returns an error.
Can I use DLookup to pull data from a query instead of a table?
Yes, the domain argument (the second parameter) in the DLookup function can be the name of a saved query just as easily as it can be the name of a table. Ensure the query name is enclosed in quotation marks.
What if I need to calculate a sum from a query in my text box?
If you need a total sum rather than a single specific field value, you should use the DSum function instead of DLookup. The syntax is similar: =DSum("FieldName", "QueryName", "OptionalCriteria").




