+ Reply to Thread
Results 1 to 3 of 3

Thread: Change Textbox value with and updateable combobox.

  1. #1
    Forum Contributor
    Join Date
    09-23-2007
    Posts
    109

    Change Textbox value with and updateable combobox.

    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.

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: Change Textbox value with and updateable combobox.

    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

  3. #3
    Forum Contributor
    Join Date
    09-23-2007
    Posts
    109

    Wink Re: Change Textbox value with and updateable combobox.

    Quote Originally Posted by davegugg View Post
    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.
    Thanks for that. Ultimately that's the conclusion I have come to as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0