populating fields from combo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want my combobox to insert the value of its 2nd column into the "Address"
field for the current record if the name was chosen from the list (the combo
is not limited to list).

So I wrote the event procedure as follows:

Private Sub Paid_AfterUpdate()
If (T_SPENT.ID = Forms!Spent.ID And Forms!Spent!Paid = S_T_Person.Name) Then
Me.Address = Me.[Paid].Column(1)
End If
End Sub

But this doesn't seem to work. :(
I am not good at writing scripts. I tried also "If () And If() Then" -
doesn't work either.

Can anybody advise me something?

Thank you.
Lana
 
Hi again, :)

I didn't know if "Me." means only currecnt record, so before I was trying to
mach the ID of the record, so the other records wouldn't change... :)

So, I have just tried the following for my combo:

Private Sub Paid_AfterUpdate()
If Me.Paid = Me.Paid.Column(0) Then
Me.Address = Me.Paid.Column(1)
End If
End Sub

And it seems to work, but once it has generated some "Unknown error" and
shut the whole Access down.

Can anybody check if my script is missing something?

Lana.
 
Lana, are you trying to save the data in the second column, while selecting
the view from the first column in the a combo box? Perhaps you can change
your bound to column and the size of your viewed columns.
 
No, I need both fields: Name and the Address.

If you are trying to copy a name and address from one table into
another table...

DON'T.

It's neither necessary nor wise to store data redundantly in two
tables like this. Store the unique personID in your second table, and
use a Query to link to it. To just *display* the name, address, and
any other desired fields, include them in the Combo's RowSource query
and put textboxes on the form with control source

=cboPerson.Column(n)

where cboPerson is the name of the combo box control, and (n) is the
zero based subscript of the field you want to see.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top