+ Reply to Thread
Results 1 to 7 of 7

Control Source Updates in Userform

  1. #1
    Registered User
    Join Date
    03-16-2004
    Location
    UK
    MS-Off Ver
    2003
    Posts
    85

    Control Source Updates in Userform

    I have a userform with various textboxes with controlsource as formulas. e.g.
    Please Login or Register  to view this content.
    etc
    There are many textboxes so I have set the controlsource programatically in the VBE.

    I also have a ComboBox with the row source linked to a range in the spreadsheet. When I change the ComboBox selection Range("MySelection") changes to the offset for the each record. However the textboxes don't update!

    Another thing, when I change the combobox the spreadsheet values don't update until I press enter. (Again it is linked with control source)

    Two Questions:
    1. How do I get the controlsource to refresh for each textbox automatically. (Do I have to reassign each value or is there a simpler way?)
    2. How do I force the spreadsheet to update on a change of combobox without having to press enter.

    Any help is appriciated greatly.
    Phil

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Control Source Updates in Userform

    If you use ContolSource then the Textbox will refresh each time the relevant cell changes, but be aware, the reverse is true. Change a TextBox & the cell will change

    Use the ComboBox Change event
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-16-2004
    Location
    UK
    MS-Off Ver
    2003
    Posts
    85

    Re: Control Source Updates in Userform

    Thanks! I think that's answered the second question but I'm still having trouble with the first. It works if I do this...

    Please Login or Register  to view this content.
    ... but it is very slow. Is there a more efficient way of refreshing the controls?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Control Source Updates in Userform

    Why not say what you are trying to do instead of what you think you need to do?

  5. #5
    Registered User
    Join Date
    03-16-2004
    Location
    UK
    MS-Off Ver
    2003
    Posts
    85

    Re: Control Source Updates in Userform

    ... to explain further:

    I have a user form that I am using to update records in a database. The records are updated by overwriting the values in the textboxes.

    I am trying to:
    A. open userform2, select a record using the combobox1, update the values in the various textboxes and then
    B. select another record and repeat the process... etc

    So far I can sucsessfully edit the first record but when I try to edit subsequent ones I find that the textbox controlsources don't update when I select a new value with the combobox and I end up overwriting my previous record.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Control Source Updates in Userform

    I wouldn't use ControlSource. Have a look at the DataBaseForm here

    http://www.excel-it.com/vba_examples.htm

  7. #7
    Registered User
    Join Date
    03-16-2004
    Location
    UK
    MS-Off Ver
    2003
    Posts
    85

    Re: Control Source Updates in Userform

    I had a look at databaseform.xls and I understand the principle but I'm not sure its quite what I need.

    I was trying something which didn't require coding the relationships between the textboxes and the data columns for each parameter (I have 42 in total). The records are unique though, which makes things a little easier.

    The beauty of controlsource is that it there is no update button to click and updates button and I can test solutions real time. (I also have calculation outputs on the form).

    A better solution might be to have two seperate user forms one to select and one to edit. This works as when the form is reloaded the textbox controlsources automatically update.

    There are various other complications: I have more than one source of data for some parameters and I want the user to be able to select the preferred source of data which would be updated to the master data record. Also for some data set the particular parameters are not relevant and their columns do not appear in the data sheet.

+ 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.6.0 RC 1