+ Reply to Thread
Results 1 to 4 of 4

Value of Active TextBox in a UserForm

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Value of Active TextBox in a UserForm

    I have a Userform which contains TextBoxes loaded with the chosen data from a database.
    Typically there are from 1 to 4 records which the choosing procedure picks up.
    I want the user to select one of these for passing on to the rest of my application.

    I had thought that some code along the lines of
    Please Login or Register  to view this content.
    would do the trick, but ActiveControl does not have a Value property.
    How should I proceed?
    John

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Value of Active TextBox in a UserForm

    Me refers to the loaded userform.

    Please Login or Register  to view this content.
    The problem will be making sure the activecontrol is the correct control when the code runs.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Value of Active TextBox in a UserForm

    andy,
    Is there an important difference between your Me.ActiveControl.Value and my Userform2.ActiveControl.Value ?
    I ask because when I tried my way I found that UserForm2.ActiveControl. did not have a Value property.

    I am a bit worried about ensuring that the correct control is active. I have thought about putting a Button beside each of the identifying TextBoxes for the user to click, but this seems a bit clunky.
    John

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Value of Active TextBox in a UserForm

    help says this about the ME keyword.

    The Me keyword behaves like an implicitly declared variable. It is automatically available to every procedure in a class module. When a class can have more than one instance, Me provides a way to refer to the specific instance of the class where the code is executing. Using Me is particularly useful for passing information about the currently executing instance of a class to a procedure in another module. For example, suppose you have the following procedure in a module:
    Either will work
    Please Login or Register  to view this content.
    you can see in the example that a button will change the activecontrol.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 23
    Last Post: 07-12-2014, 07:09 PM
  2. Fill textbox in each active UserForm
    By Laik2013 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-22-2014, 04:12 PM
  3. [SOLVED] Userform textbox to reference active cell with offset
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 6
    Last Post: 12-15-2013, 01:38 AM
  4. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  5. Userform Textbox updating a another userform textbox (im stuck!!)
    By wapwap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2011, 02:56 PM

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