Saving the 2nd column...

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

Guest

I have a combo box that pull data from 2 columns, I can get it to save the
bound column in a table but I need to have it save the 2nd column in a
different field on the same table.

I was told I could do this with a code but I have no idea where to begin on
this.

Any help on this would be greatly appreciated!

Thank You
 
Bound the DifferentFieldname to the field in the table, so it will save the
data in the table.
On the after update event of the combo you can write the code

me.DifferentFieldname = me.comboName.Column(1) ' Assuming that the value
is in the second column of the combo, if it's in the first one then change
the 1 with 0.
 
You can add code to the After Update event of the combo box.

Me.txtDifferentField = Me.cboYourCombo.Column(1)

This would be in a module window. Column numbers start with 0.
 
Joel

Are you saying you want to store two facts from your lookup table (via the
combo box) into another table? Why?

If you are storing the bound column (usually the rowID for the lookup
table), you can forego storing the looked up value -- you (and Access)
already have a way to derive the looked up value.

Redundantly storing the same fact in multiple tables is not a good design
approach.

Now, if you're talking about DISPLAYING the looked up value in a form, the
other responders have already addressed this.
 
Thanks for the help guys but im getting this error when i put that code in

Compile error: Meathod or Data not found

I out in:

Me.AreaNumber = Me.Combo81.Column(1)

and it highlights this part:
..AreaNumber =

I checked the spelling and its correct.
 
Im not saving the data twice, this is for an input form to save on typing.

I have all the locations i want on the list in a table with there names in
one column and there number in another column. Now when you select the name
 
Ok I got it.

All I did was change this:
Me.AreaNumber = Me.Combo81.Column(1)

to

Me!AreaNumber = Me.Combo81.Column(1)

and it works great!

Thanks again guys!
 
Are you sure that the name of the field o the form is AreaNumber, it might be
the name of the field in the table, but not in the form.
 
Im not saving the data twice, this is for an input form to save on typing.

I have all the locations i want on the list in a table with there names in
one column and there number in another column. Now when you select the name
on the form, I want it to save the name in one column (on a differnet table)
and the number in another column.

Well... No. You DON'T want to do this.

If you can always find the name given the number (or vice versa) by a
Query, then only *one* of them should be stored in this table.

Storing both the name and the number in your target table wastes
space, but much more importantly, risks data corruption. What if you
have a Number stored, and the name associated with that number gets
changed in the lookup table? You now have a name in an unknown number
of records in your table, *AND THAT NAME IS WRONG*.

Simply store the unique ID from the lookup table, and then use a Query
to display it on a report, or a Combo Box to display it on a form.
There is NO benefit to storing both fields, and many disadvantages!

John W. Vinson[MVP]
 
Joel

I may be reading what you're typing differently than you intended it. It
still sounds like you are trying to "save the name in one column ... on a
different table". I'm interpreting this to mean you use a combo box to find
a name and ID in one table (i.e., a lookup table), then, via the form, save
that name (?and ID) in a different table.

What am I misunderstanding? (If I am not misunderstanding, then don't do
it!)

Jeff Boyce
<Access MVP>
 
Back
Top