Control Source question

A

Andy Levy

I have a text box on a form. The forms control source is tableA

However I want the text box's control source to be a value from tableB.

In this sort of way :

"SELECT [tableB].[fieldX] FROM [tableB] WHERE [tableB].[fieldY] = " &
me.fieldZ

Thanks for any help

Andy
 
F

fredg

Andy said:
I have a text box on a form. The forms control source is tableA

However I want the text box's control source to be a value from tableB.

In this sort of way :

"SELECT [tableB].[fieldX] FROM [tableB] WHERE [tableB].[fieldY] = " &
me.fieldZ

Thanks for any help

Andy
Andy,
If you wish to get a value from a table not included in your Form's
recordsource, use a DLookUp().

=DLookUp("[FieldX]","tblB","[FieldY] = " & Me![FieldZ])

The above assumes FieldY and FieldZ are a Number Datatype.
You will need to change that where Clause if they ara a different
datatype.
See Access Help regarding:
DLookUp + Where Clause + Restrict data to a subset of records
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top