Select Data from subform

  • Thread starter Thread starter Daveo
  • Start date Start date
D

Daveo

Hi there,

I'm trying to select some data from a subform and display it in a text
box on my main form.

The fields in my subform are:

employee
site
dateFrom
dateTo
desk
PC

The main form is called "frmCairnsOfficeTester" and the subform is
called "frmSpaceTester"

I want to display the employee who is sitting at desk 1 in the text box
and so put the following as the control source in the text box:

SELECT frmSpaceTester.[employee] FROM frmSpaceTester WHERE
((frmSpaceTester.[desk]="Desk 1"));

All I get in the text box is #Name?. I know I'm doing something wrong -
does anyone know what it is?

Many thanks - David
 
You cannot use a SQL statement as the Control Source for a text box.

You could use DLookup() to read the value from the table, e.g.:
=DLookup("Employee", "tblSpaceTester", "Desk=""Desk 1""")
 
Back
Top