SELECT statement as Control Source

  • Thread starter Thread starter Louis
  • Start date Start date
L

Louis

Hi - I have an Unbound Text Box on my Continuous Form in Access 2000.

The Control Source of the Form is TableA

I would like to set the Control Source of the text box to a value that is
from another table using a SELECT statement. But i cant seem to get it
right.

ie Text Box Control Source : SELECT TableB.ref FROM TableB Where TableB.id
= [tableb_link_id]

[id] is the id of the record to look up on trable b based on the value in
table A. The relationship is 1 - 1.
 
You can't use a SELECT statement as the Control Source for a textbox -- or
any other control for that matter. However, you CAN use the DLookUp
function:

Text Box Control Source: =DLookUp("Ref", "TableB", "[ID] = " &
tableb_link_id)

This assumes that ID and tableb_link_id are numeric values. Also, the
control source must start with the equal sign.

--
--Roger Carlson
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Ah yes - thank you
Roger Carlson said:
You can't use a SELECT statement as the Control Source for a textbox -- or
any other control for that matter. However, you CAN use the DLookUp
function:

Text Box Control Source: =DLookUp("Ref", "TableB", "[ID] = " &
tableb_link_id)

This assumes that ID and tableb_link_id are numeric values. Also, the
control source must start with the equal sign.

--
--Roger Carlson
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

"Louis" <lou> wrote in message news:[email protected]...
Hi - I have an Unbound Text Box on my Continuous Form in Access 2000.

The Control Source of the Form is TableA

I would like to set the Control Source of the text box to a value that is
from another table using a SELECT statement. But i cant seem to get it
right.

ie Text Box Control Source : SELECT TableB.ref FROM TableB Where TableB.id
= [tableb_link_id]

[id] is the id of the record to look up on trable b based on the value in
table A. The relationship is 1 - 1.
 
Back
Top