default value in text box on form based on sql

G

Guest

Hi

many times i create forms that require the user to select an employee on
form using a pull down menu. then based on that, the user wants to see (and
record in a table) the social security of this employee. i can get this using
a sql script. however, i would need to use a pull down menu. this is
annoying, because the user needs then to go to the pull down menu and select
the result. i would like it to come up automatically.

i tried today to use a list, but i had a short coming with that as well. the
selection would only be recorded if the user clicks on the list. (i think
that i had some other complications like refreshing the data, but this i am
sure i can resolve).

i want to avoid using vb if i can, first because i think sql is more
efficient, second i am not a vb expert.

anybody know what is the best way to do this?

thanks,

sam
 
W

Wayne Morgan

Is the SSN available in the same table as the name that fills the pull down
list (combo box)? If so, just add another column to the combo box and add
the SSN field to the combo box's Row Source. Set the width of this column to
zero to hide it. In the AfterUpdate event of the combo box, assign the value
of this column to the textbox. The column index number is zero based.

Example:
Me.txtMytextbox = Me.cboMyCombobox.Column(2)

If the SSN is in a different location, use the AfterUpdate of the combo box
and the DLookup() function to assign the value to the textbox.
 
G

Guest

hi wayne,

thanks so much. i used VBA using method one, it it worked like a charm. i
tried it with a macro, but i had problems with the third and fourth one. so i
changed to VB and it worked fine.

i will post seperately another question i have today.

in the meantime, thanx a lot,

sam
 

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