field value from another table

G

Guest

Hi!
I have a form inside another form
in this form i have a combobox when i select a value in this
combobox i want to antoher field shall take the value from another
table based on the value from the combobox
I can do this if the field is a combobox then i can make
query to this fields value but i can't see how to make a query to
a simpel text fields value ?
Remember the field is in one table and i want to get the value to this field
form another table

Hope some one can help

regards alvin
 
M

Marshall Barton

alvin said:
I have a form inside another form
in this form i have a combobox when i select a value in this
combobox i want to antoher field shall take the value from another
table based on the value from the combobox
I can do this if the field is a combobox then i can make
query to this fields value but i can't see how to make a query to
a simpel text fields value ?
Remember the field is in one table and i want to get the value to this field
form another table


But, how are the two tables related? Assuming that the
combo box's value is a foreign key to a specific record in
the other table, you can use the DLookup function to
retrieve the value from the other table:

=DLookup("somefield", "othertable", "keyfield=" &
Me.combobox)

OTOH, it is often more efficient to create a query that
joins the two tables on the linking fields, then use the
query as the combo box's row source. This way the desired
field can be retrieved from the combo box by referencing the
desired field using the Column property:

=combobox.Column(N)

where N is the 0 based number of the field in the query.
 

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