Return a default value in a textbox

  • Thread starter Thread starter Brutalius
  • Start date Start date
B

Brutalius

I have created a form with a dropdown list of Names referenced from Column A
in Table 1. I would like a textbox on the form to automatically display the
appropriate phone number in Column B of Table 1. How is this done?
 
Make sure the source of the combobox has the phonenumber field in it (add it
if necessary).

Now in the after update event of the combobox place the following line of
code:

me.textbox=me combobox.column(1)

where me.textbox should read the name of the textbox where you want the
phonenumber to appear in. The me.combobox should be replaced by your
comboboxname. The (1) refers to the second field in your combobox which
should be your phonenumber.

hth
 
That worked great. Thanks!

tkelley via AccessMonster.com said:
More than one option:

DLookup function:

In the after update event of the dropdown, use DLookup. You'll be better off
to add your PK field to your rowsource (if it isn't already), then set it's
width to zero. Then you can use Dropdown.value as the criteria in the
DLookup

or

Column property of your dropdown:

Add column B to your rowsource for the dropdown, set it to 2 columns, set the
new column width to zero (to hide). Then on the after update of the dropdown:


me.txtPhoneNum = me.Dropdown.Column(1,me.Dropdown.listindex)

(I prefer this one, especially when I'm trying to save trips to the backend)
 
Brutalius said:
I have created a form with a dropdown list of Names referenced from
Column A in Table 1. I would like a textbox on the form to
automatically display the appropriate phone number in Column B of
Table 1. How is this done?

There are several ways and it depends on what you are doing with the
information.
If, for example, you have an invoice and wish to look up a billing name and
phone number
then you should just store the Key from the name table in your invoice
table.
The form would be based on a query relating the Invoice to the Name table.
Selecting a name would display the name and address from the name table.

*Any* other method will cause problems if the phone number changes.
 
Back
Top