combo box and saving to table

  • Thread starter Musa via AccessMonster.com
  • Start date
M

Musa via AccessMonster.com

I can select 1 value from a 2 column combo box and save it....no problem. I
can even display the 2nd value of the combo box in a text field. But, is
there a way to select 2 values from the combo box and save column(0) to one
field and column(1) to another field in the same table ?

For Example, ID -- 10 Name --- ABC Company

It saves as: ID Name
10 ABC Company

I know this is against normalization and it would be redundant data, but can
it still be done..?

Thanks
 
J

John W. Vinson

I can select 1 value from a 2 column combo box and save it....no problem. I
can even display the 2nd value of the combo box in a text field. But, is
there a way to select 2 values from the combo box and save column(0) to one
field and column(1) to another field in the same table ?

For Example, ID -- 10 Name --- ABC Company

It saves as: ID Name
10 ABC Company

I know this is against normalization and it would be redundant data, but can
it still be done..?

Thanks

You're right, it's almost certainly a Bad Idea (what if ABC Company gets
bought out and becomes Steele, Robb and Plundre)? but...

Use the AfterUpdate event of the combo to "push" data into a textbox bound to
the other field:

Private Sub cboCompany_AfterUpdate()
Me!CompanyName = Me!cboCompany.Column(1)
End Sub

using the first column as the bound column...
 
F

fredg

I can select 1 value from a 2 column combo box and save it....no problem. I
can even display the 2nd value of the combo box in a text field. But, is
there a way to select 2 values from the combo box and save column(0) to one
field and column(1) to another field in the same table ?

For Example, ID -- 10 Name --- ABC Company

It saves as: ID Name
10 ABC Company

I know this is against normalization and it would be redundant data, but can
it still be done..?

Thanks

1) You're correct....This is redundant data and should not be done.

2) However, if you had some compelling business reason, code the Combo
box AfterUpdate event:
Me.[Name] = Me.ComboName.Column(1)

The field Name should be included on the form.

3) See #1

Note: I hope you do NOT have a field named "Name" in your table.
Name is a reserved keyword and should not be used as a field name.
 
M

Musa via AccessMonster.com

No, field is labelled Name... Thanks for your suggestion.
I can select 1 value from a 2 column combo box and save it....no problem. I
can even display the 2nd value of the combo box in a text field. But, is
[quoted text clipped - 10 lines]

1) You're correct....This is redundant data and should not be done.

2) However, if you had some compelling business reason, code the Combo
box AfterUpdate event:
Me.[Name] = Me.ComboName.Column(1)

The field Name should be included on the form.

3) See #1

Note: I hope you do NOT have a field named "Name" in your table.
Name is a reserved keyword and should not be used as a field name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top