Need help with updating combo box value from another combo box in Microsoft Access using VBA

stephenlecomptejr
stephenlecomptejr used Ask the Experts™
on
How to force the same value in another combo box from another combo box?

All please note the following sample file.
Basically after someone selects a value in ComboA - it supposed to make ComboB - appear with the same value in another table.

How do I do this with VBA code in the AfterUpdate event?

Again, I provided a sample so it would be easy to try.  Please note the two tables have similar values but different field names
Thanks in advance..

Private Sub cboA_AfterUpdate()
  
  Dim sCompany As String
  sCompany = cboA.Column(1)
  'MsgBox (cboA.Column(1))
  
End Sub

Open in new window

Database1.accdb
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
This works for me:

Private Sub cboA_AfterUpdate()
  
    Dim sCompany As String
  
    sCompany = Me!cboA.Column(1)
    Me!cboB.Value = DLookup("ID", "[Company]", "[ItemNames] = '" & sCompany & "'")
     
End Sub

Open in new window

John TsioumprisSoftware & Systems Engineer

Commented:
Would you mind giving some more info why you want such kind of duplication...the combobox was invented in order to retyping the same and same values...so select it once ...use it many.

Author

Commented:
Thanks for providing the answer.  I appreciate it.

No can do John but thank you for the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial