Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Textbox 'Control Source' to be a Query?

Status
Not open for further replies.

Reimondo

Technical User
Feb 26, 2003
26
AU
Hi,

Is it possible to set the 'Control Source' of a text field box to be a query? The text box is unbound (ie. not a physical field in the database tables).

I've already got the query and it works fine when I execute the query by itself. But when I assign the query to the 'Control Source', I get a #Name error when I load the form. So I'm now thinking whether Access supports the assignment of a 'query' as a 'control source'?

Any help will be much appreciated.

Thanks,

Raymond
 
Access doesn't support that.

Have a look at the DLookup function in the help files, that might be used as controlsource (or you could open the query as a recordset using VBA and DAO/ADO and assign the value).

Syntax:
[tt]=DLookup("field","table","somefield = somevalue")[/tt]

Criteria part might be omitted.

Roy-Vidar
 
Change your unbound text box to a combo box. You can set the combo box to only show one row and lock/disable it to prevent data entry into the control.

HTH

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top