Can I use one combo box to populate two fields VendorID & VendorNa

  • Thread starter Thread starter Jim in Spokane
  • Start date Start date
J

Jim in Spokane

SELECT dbo_VENDOR.ID, dbo_VENDOR.NAME, dbo_VENDOR.ID+' - '+dbo_VENDOR.NAME AS
VendorIDName
FROM dbo_VENDOR

Seems I can only get one or the other.

Do I need to use additional expressions or coding?

Thanks!
 
First change the name of the field "Name" to something like "VendorName".
Name is a reserved word in Access and many programming languages.

In the AfterUpdate event of the combo, set the Name field, like:

Private Sub cboVendor_AfterUpdate()
Me.txtVendorName = Me.cboVendor.Column(1)
End Sub
 
SELECT dbo_VENDOR.ID, dbo_VENDOR.NAME, dbo_VENDOR.ID+' - '+dbo_VENDOR.NAME AS
VendorIDName
FROM dbo_VENDOR

Seems I can only get one or the other.

Do I need to use additional expressions or coding?

Thanks!

Unless you have some very unusual requirement, you *should't* do this. Storing
the Vendor Name redundantly in a second table is generally a Bad Thing To Do.

Just store the vendor ID, and use a Query (or a Combo Box or a DLookUp or any
of a lot of other tools) to display it when needed. If you store the name in
both tables, you're wasting space and risking data corruption if one of the
table's VendorName field gets edited and the other doesn't.
 
Back
Top