auto filling a textbox!! PLZ HELP

V

Varsha

Hi!
I have a data entry form with numerous controls. This
form was not linked to any table when it was designed.
What I want to accomplish is when a user selects a value
from say combo1, it should go to table1(which has 2
columns), look that value up from table1 (column1), find
a matching record and display the corresponding value
from column2 of the table in some textbox called text1 on
my form.

I have been trying to use the OnExit event of combo1, but
am not sure whether thats where I write the code. I do
not know how to associate a query that would populate my
textbox with the desired value.

THANKS
 
J

J. Clay

I would use the AfterUpdate event of the combo box.

Your Query statement would look something like:
strSql = "SELECT value FROM Table WHERE key = '" & me!combo1 & "'"

This is assuming that Combo1 is returning a string (Note the single quotes).

HTH,
J. Clay
 
W

Wayne Morgan

I would use the AfterUpdate event of the Combobox to do this in code. You would then set
the value of the textbox.

Me.Text1 = DLookup("[Column2]", "Table1", "[Column1] =" & Me.cboMyCombobox

You should also be able to do this by making the textbox a calculated control. Place the
above, from the = to the end but without the "Me.", in the Control Source of the textbox.
 

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