Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Return a default value in a textbox

Geek News

Return a default value in a textbox
Brutalius 12/29/2008 10:17:02 PM
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?
RE: Return a default value in a textbox
Maurice 12/29/2008 10:26:01 PM
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
--
Maurice Ausum


"Brutalius" wrote:

[Quoted Text]
> 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?
Re: Return a default value in a textbox
"tkelley via AccessMonster.com" <u47368[ at ]uwe> 12/29/2008 10:40:37 PM
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 wrote:
[Quoted Text]
>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?

--
Message posted via http://www.accessmonster.com

Re: Return a default value in a textbox
Brutalius 12/29/2008 11:04:03 PM
That worked great. Thanks!

"tkelley via AccessMonster.com" wrote:

[Quoted Text]
> 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 wrote:
> >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?
>
> --
> Message posted via http://www.accessmonster.com
>
>
Re: Return a default value in a textbox
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 12/30/2008 2:27:05 AM
Brutalius wrote:
[Quoted Text]
> 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.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net