I'm trying to get a combobox to do two things.
1 - When I change combobox1 (sourced from the first column in table 1), a textbox is updated from the corresponding value in column 2 of the same table.
2 - I want the combobox to be updateable so it amends the value in the currently referenced by that combobox in the corresponding table it is referencing. Basically I want to be able to manually amend the value in the combobox and have it update Table1.
I achieve step 1 by using an event in the 'After Update' event of combobox1. The code is below. This works fine providing I set the column count to 2 in the combobox1 properties. So what happens is, when I change the value in the combobox it updates the textbox with the corresponding value in Table1.
Private Sub combobox1_AfterUpdate() Me.Textbox1 = Me.Combobox2.Column(1) End Sub
The problem I'm having is this. I am unable to update the value in the combobox manually. Obviously this clashes with the 'After Update' event. I would like the combobox to be used for both selecting values (using the dropdown feature of a combobox) and used as a manual input field in a userform to update a table.
Any clues as to whether this can be achieved. Should I not be using an event in this case?
Thanks very much.
Last edited by danny2000; 07-14-2011 at 10:36 AM.
In what way are you unable to update the value in the combobox manually? What is your code that currently attempts this? You should be able to either do this with a simple UPDATE SQL statment or by opening the table as a recordset and updating the record.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks