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.
combobox on userform dependent on one another
Collapse
X
-
Tags: None
-
gunjanbhatia48,
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. -
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.Comment
-
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.displays ID correspond to that in excel (source).Last edited by zmbd; Apr 30 '19, 04:43 AM.Comment
Comment