drop down

  • Thread starter Thread starter Evelyn Ballantyne
  • Start date Start date
E

Evelyn Ballantyne

I have a form based on a table with names and addresses
stored. the primary key is an auto number

I have put a combo box for the surname (using the primary
key field and hiding it) and can call up the surname but
the rest of the details for that record do not go into
text boxes on the form.
 
Hi,
If you create your combo with the wizard, it will write the code for you to make
this happen.
If you've already tried that, post back with more info.
 
I first created a table called "Tnames_and_addresses" -
field "code" (auto number primary key)
field "surname"
field "first_name"
5 fields for 5 lines of address.
THEN created a form based on this table. putting all the
address fields from the field list. then created a combo
box using the wizard. "which table or query should
provide the values for your combo box?" I
chose "Tnames_and_addresses"
Values in the combo box - "code" "surname" "first_name"
ticked "remember value for later use" as i didnt want to
store it -
FINE. I can select the correct full name -
BUT it does not update the address textboxes on the form.

I also tried setting the combo box properties - row
source to SELECT DISTINCTROW but that didnt work.

Also did a complete new database with just the one table
and one form to try it all again, cant see what I am
doing wrong.





-----Original Message-----
Hi,
If you create your combo with the wizard, it will write the code for you to make
this happen.
If you've already tried that, post back with more info.

--
HTH
Dan Artuso, Access MVP


"Evelyn Ballantyne" <[email protected]> wrote in
message news:[email protected]...
 
Hi Evelyn,

You can use the AfterUpdate event and the Column property
of the ComboBox to achieve your goal. I'll try my best to
explain this below. E-mail me if you need further help.

Let's assume your combo box is named Combo0.

Let's also assume you have 3 text boxes named Text1, Text2
and Text3 for
Code:
, [surname] and [first_name], where
Text1=[code], Text2=[surname] and Text3=[first_name].

In the form's design view, select the combo box, open up
it's properties and click on the elipsis (...) following
the line that says "After Update" under the Events tab.
(Are you with me so far ?).

This will take you to the code window, and automatically
generate the following code for you (you could have also
pressed Alt+F11 but then you would have to type all code
manually):


Private Sub Combo0_AfterUpdate()

End Sub


What you need to do now is to enter the following 3 lines
in between the code generated, as shown below.


Private Sub Combo0_AfterUpdate()

Me.Text1 = Me.Combo0.Column(0)
Me.Text2 = Me.Combo0.Column(1)
Me.Text3 = Me.Combo0.Column(2)

End Sub


This will update all your text boxes as soon as you select
any item in the combo box.  You are probably currently
using code like Me.Text2 = Me.Combo0 which will only
return the column you selected in the wizard upon being
prompted to select value for later use. Using the Column
property of combo box gives you control over all the
columns in the combo box.

Hope I was able to explain it properly to you.

Regards - Behram
 
Hi,
In the very first dialog that the wizard brings up,
you should have a choice:
"Find a record on my form based on a value in my combo box"

Choose that and it will create it for you.
 
THENK YOU SO MUCH - GREAT, I SHOULD HAVE NOTICED THAT!!!!
-----Original Message-----
Hi,
In the very first dialog that the wizard brings up,
you should have a choice:
"Find a record on my form based on a value in my combo box"

Choose that and it will create it for you.

--
HTH
Dan Artuso, Access MVP


"Evelyn Ballantyne" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top