Update a table with 2 concatenated fileds

B

beavetoots

I have a form that has a club and a branch. I don't want to have users
having to data enter the combined field:
frm_data!combo_field = rtrim([club]) & Rtrim([branch])

I can get it to show the combined field in the form, but can't get it to
write back to the table that the form is based on:

tblZip.comboKey = Forms!frm_data!combo_field

Can somebody tell me how to get this to update the table?
 
F

fredg

I have a form that has a club and a branch. I don't want to have users
having to data enter the combined field:
frm_data!combo_field = rtrim([club]) & Rtrim([branch])

I can get it to show the combined field in the form, but can't get it to
write back to the table that the form is based on:

tblZip.comboKey = Forms!frm_data!combo_field

Can somebody tell me how to get this to update the table?

Don't.
Keep the data in 2 separate fields.
Anytime you need the combined data, combine it, in a query, form, or
report, using the same expression you are now using:
=rtrim([club]) & Rtrim([branch])
 
B

beavetoots

well ... I tried putting that in as a default field .... it wouldn't really
do anything ...
what I ended up doing was this:

Private Sub Branch_Exit(Cancel As Integer)
Dim ComboKey As String
ComboKey = (RTrim([Club]) & RTrim([Branch]))
Forms!ziptable!CombinedKey = ComboKey
End Sub



fredg said:
I have a form that has a club and a branch. I don't want to have users
having to data enter the combined field:
frm_data!combo_field = rtrim([club]) & Rtrim([branch])

I can get it to show the combined field in the form, but can't get it to
write back to the table that the form is based on:

tblZip.comboKey = Forms!frm_data!combo_field

Can somebody tell me how to get this to update the table?

Don't.
Keep the data in 2 separate fields.
Anytime you need the combined data, combine it, in a query, form, or
report, using the same expression you are now using:
=rtrim([club]) & Rtrim([branch])
 
J

John Vinson

I have a form that has a club and a branch. I don't want to have users
having to data enter the combined field:
frm_data!combo_field = rtrim([club]) & Rtrim([branch])

I can get it to show the combined field in the form, but can't get it to
write back to the table that the form is based on:

tblZip.comboKey = Forms!frm_data!combo_field

Can somebody tell me how to get this to update the table?

If you're trying to store a combined key, redundantly... DON'T. It's
neither necessary nor good practice!

The table should NOT HAVE a field named comboKey if it also has fields
Club and Branch. The field should simply *not exist*. If the
combination of the two fields is a primary key, simply select both
fields in table design view and click the Key icon to make them a
joint, two-field key.

John W. Vinson[MVP]
 
Top