Transferring data between controls

  • I'm sure the answer to this is staggeringly simple but I'm stumped. I have a userform and I want to assign the value of a combobox to a textbox when a command button is pressed. However, nothing shows up in the textbox. If I 'transfer' the combobox value to the textbox and then to a worksheet (as below), it shows up in the sheet but the textbox is blank. What simple thing am I missing?


    Quote

    txtBox.Value = cboMet.Value
    ActiveCell.Offset(11, 0) = txtBox.Value

  • Re: Transferring data between controls


    This works for me,



    Are you sure that your controls are correctly named/referred to ?

  • Re: Transferring data between controls


    Thanks Will. I copied your example and it works for me too. Could the problem be related to the fact that I am using a multipage? Everything is on the same page, and I have tried using the full reference (multipage1.pages(0).textbox.value etc) but to no avail.

  • Re: Transferring data between controls


    Will, it gets curiouser and curiouser. I cut the file right down so that I could upload it here, and when I tested it it worked! So, the problem must lie in the bits I removed but the full file is 180Kb so I don't think I can upload it.

  • Re: Transferring data between controls


    Quote from StephenR

    So, the problem must lie in the bits I removed


    Did you remove any code ?



    Quote from StephenR

    but the full file is 180Kb so I don't think I can upload it.


    Try zipping it ?

  • Re: Transferring data between controls


    This is somewhat embarrassing as I've just noticed an 'Unload Me' which I thought I'd commented out. Sorry for wasting your time! However, this does lead me to another problem. Is there a way to unload one page of a multipage form.

  • Re: Transferring data between controls


    The Unload statement generally is limited to the Form Object.


    A multipage control is by nature an embedded control on your form. So as such it cannot ever be unloaded (only by unloading the parent i.e. the form)


    A bit of an explanation about your project might help us to help you here.

  • Re: Transferring data between controls


    OK. The user completes the form and can add any number of records, which are stored on the pressing of a command button (which also unloads the form so they can enter a new record). I want them to be able to look back on records they've previously entered and, if necessary, amend or delete them. I thought of putting the user-input bit on one page of a multipage and the stored values (in textboxes) on the second page. Given your explanation, perhaps it would be simpler to place the stored values in a separate form. Thanks in advance for any suggestions.

  • Re: Transferring data between controls


    When you say


    Quote from StephenR

    OK. records, which are stored on the pressing of a command button (which also unloads the form so they can enter a new record).


    Do you mean that the records are stored in the worksheet ?


    If so, there are better ways to edit existing records. I'd recommend using a dedicated userform if the excel data from can not be used.

  • Re: Transferring data between controls


    Quote

    Do you mean that the records are stored in the worksheet ?


    Well, they are stored in the worksheet (for my purposes), but I also wanted to store them in a form for the user to edit. From what you say it makes sense to have a separate userform rather than different pages of a multipage.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!