load data into a textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have 2 tables: tableA has field1 (key), and tableB has field1 (related
to field1 from tableA, and field2).
In the form, I have a listbox (populate text from tableAField1, and a
textbox.
What I m trying to do is when the user selects an entry from the listbox
I'd like to display the corresponding field2 from tableB where tableb field1
= selected item on the listbox.
Is there a way to do that?
 
There are few options
1. the source of the list box combain the two tables
select Field1 , field2 From Table1 inner ....

So when you select the record in the list box the value of field 2 is
selected als0
in the source of the text box you should write
=Forms![FormName][ListName].column(1) ' specify the right location when it
start with 0

2. The source of the list box is table 1
Instead of a text box you can create a combo box and it source will be
select field2 from table2 where field1=forms![formname].[ListName]

On the after update event of the list box you should write
me.comboname.requery

3. create a text box with a dlookup in it source
= dlookup("field2","Table2","Field1=" & forms![Formname].[ListName]) ' If
number
= dlookup("field2","Table2","Field1='" & forms![Formname].[ListName] & "'")
' If Text
 
Back
Top