Help using a query as the control source (text box)

  • Thread starter Thread starter Stuart E. Wugalter
  • Start date Start date
S

Stuart E. Wugalter

I have the following query:

SELECT TOP 1 tblSeqTaq.TAQCALL
FROM tblSeqTaq
WHERE (((tblSeqTaq.TAQCALL)="Allele 2"));

The query returns one record containing the text "Allele 2"

I tried to use this query as the control source for a list box:

=qrySelectAllele2!TAQCALL

The result is #Name? on the form.

Any suggestions would be greatly appreciated.

Thanks in advance, Stuart

Stuart E. Wugalter
Statistician II
Building: PMB B100
Mail Code: 9011
Department: Zilkha Neurogenetic Institute
Division: Keck School of Medicine
Telephone: (323) 442-1080
FAX: (323) 442-3054
E-Mail: (e-mail address removed)
 
Stuart said:
I tried to use this query as the control source for a list box:

=qrySelectAllele2!TAQCALL

The result is #Name? on the form.

Any suggestions would be greatly appreciated.

=DLookup("TAQCALL","qrySelectAllele2")

will do.
 
Hi Stuart

The ControlSource can be one of three types:
1. The name of a field in the form's RecordSource (this is called a
bound control, because any change in the control's value is reflected in the
underlying record, and vice-versa)
2. An = sign, followed by an expression (this is a calculated control,
and the value is always read-only)
3. Blank (this is called an unbound control, and the value is whatever
the user types into it, or whatever it is set to by code)

You are trying to combine 1 and 2, referring to a field of a query that is
not the form's RecordSource.

If this is really what you want to do, then you can either (a) include the
other table in the form's recordsource (if possible) and bind the control to
the required field, or (b) use the DLookup function in a calculated
ControlSource to look up the field in the table or query.

HOWEVER... if things are as you state, then your query result can be nothing
except "Allele 2". I'm not sure what you're trying to achieve, but you can
get the same result by setting the ControlSource to:
="Allele 2"

Maybe you could follow up with some clarification of your intentions?
 
Back
Top