Display query results in a textbox

dbfromnewjersey
dbfromnewjersey used Ask the Experts™
on
How do I display the result of the following query in a textbox on my access form?

 SELECT [Query3].[Current Balance] FROM Query3;
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Architect / Application Developer
Top Expert 2007
Commented:
One way, from some where in VBA code, like behind a command button - assuming your SELECT statement ONLY returns ONE record:


Me.YourTextBoxName = CurrentDb.OpenRecordset("SELECT [Query3].[Current Balance] FROM Query3", dbOpenDynaset)

mx
Top Expert 2010

Commented:
Another way, from the form/report design view:

=DLookup("[Current Balance]", "[Query3]")

This likewise assumes there is only ever a single result.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Another way, when you can create an expression right in the text box:

Save that SQL as a saved query ... lets call it qryCurrBal.

Then, in the Text box Control Source, do this=

=DLookup("[Current Balance]","qryCurrBal")

including the equals sign.

mx

Author

Commented:
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial