By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 IT Pros & Developers. It's quick & easy.

combobox on userform dependent on one another

P: 1
I have two combo box on a user form "Name" and "ID". When I select name, it automatically displays ID correspond to that in excel (source). I want, if I put either of the information (ID or name) other one automatically displays.
3 Weeks Ago #1
Share this Question
Share on Google+
3 Replies

Expert Mod 2.5K+
P: 3,158

Welcome to Bytes!

What have you tried so far? Without knowing anything more about your project we can't provide any solid advice.

As initial advice, I would recommend changing the names of your Combo Boxes to "cboName" and "cboID". First, because "Name" is a reserved word in the Access engine, and second, because this will disambiguate between the Combo Box itself, an underlying field named "Name" (which you should never do in the first place), the Name of the Combo Box, and the Name of hte Form. This is not an answer to your question, but just some helpful advice for the future.
3 Weeks Ago #2

Expert Mod 15k+
P: 31,302
First of all twinny's advice is well worth following.

Now let's get to your question. There's very little here, as Twinny says, so any response will necessarily be very limited. You really do need to start by giving careful consideration to exactly what it is you're trying to achieve before asking the question. Imagine trying to give any sort of reliable answer when you haven't really even finished working out what the question should be.

However, speaking generally, and this is working on the basis you're dealing with unbound ComboBoxes rather than any sort of bound Form, You could have two ComboBoxes (Called [cboName] & [cboID]) with very similar ControlSources and in the AfterUpdate event of both have code that sets the other one to the matching value. Setting a ComboBox to the entry you require basically involves setting the .Value of the ComboBox to the value of the entry.
3 Weeks Ago #3

Expert Mod 5K+
P: 5,327
displays ID correspond to that in excel (source).
Also gunjanbhatia48, you need to clarify if this is in an Excel workbook, a linked table within Access to an Excel Workbook, or data imported from excel into an Access database as the method of solution may be drastically different, that is to say, a solution that works for the Excel workbook will not usually be available in Access or vice/versa.
2 Weeks Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.