+ Reply to Thread
Results 1 to 13 of 13

setting focus with click of command button

Hybrid View

  1. #1
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    setting focus with click of command button

    Hi All

    I cannot seem to be able to set the focus on multipage1 to combobox1 when i click command button 2

    When i use setfocus cmd i get object not supported or some like statement
    can anyone shed a little light on this please

    Jamesspeedway staking plan 1.1.2.xlsm

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: setting focus with click of command button

    At the Bottom of your code for CommandButton2 on the Userform add this line:

    Me.ComboBox1.SetFocus
    Hope it helps!
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: setting focus with click of command button

    I just had another look at your Userform. It seems that you expect CommandButton2 to handle a magnitude of variables.

    Best would be to Create a "Start" Button for each "Multiple" Sheet in your Userform, and add code to each one such "Start" Button to take care of its own procedure. Of course you would also have to add code to "Hide" the other two Buttons when any one of the other three is "Active".

  4. #4
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    Can anyone tell me why the setfocus won't work? Seems strange
    any way I have opted for a new userform to enter target and bank data (that should get the fbi going) And hopfully find a solution to the focus part in due time

    Happy days James

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: setting focus with click of command button

    Hello James,

    If you do what I gave you in Post#2, CommandButton2 works just fine with Page 1 of the Multi-Page Userform. To keep it simple, and easy to code & maintain, it would be best if you created a seperate such CommandButton, each with its own unique code, for each one of the remaining individual pages of the Multi-Page Userform.(See my last post-#3)

    You may stack these CommandButtons on top of each other, and simply control its appearance/s with Visible=True or False. To the user it will appear as just one Button.

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: setting focus with click of command button

    You need to have the correct tab active

        Me.MultiPage1.Value = 0
        Me.ComboBox1.SetFocus
    PS It would also be polite to respond to replies you get.
    Good luck.

  7. #7
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    Thank you both I will look at it againg in the morning

    got work now
    James

  8. #8
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    Thanks Winon
    That i never thought of. And incidently have accidentally done by copying a button then hitting paste and losing the copies. then getting in a right old pickle when these mysterious command buttons try to take over the world (you would know what i mean if you had done it)

    At the moment I am thinking more upon the lines of separate user forms to get to the origional form and the multipage focus
    The first is a "before we begin" form in which you enter Target and bank - i can then do away with the two text boxes and button 1 on origional form

    the second user form is an instruction form which pops above the multipage to prevent data being entered without knowing what if you see my meaning

    Here it is

    speedway staking plan 1.1.2.xlsm

    James

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: setting focus with click of command button

    The .TakeFocusOnClick property of CommandButton2 should be False, if it is going to sent the focus to another control.

    This snippet can be edited when Page3 gets some controls.
        With Array(ComboBox1, ComboBox5, ComboBox1)(MultiPage1.Value)
            .SetFocus
        End With
    Last edited by mikerickson; 01-22-2012 at 02:41 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  10. #10
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    Hi
    Yes tried it and its ok when page one of multipage is to the front in the vba editor but if i have been tinkering and leave page 3 to thr fron for instance then it all goes horribbly wrong
    James

  11. #11
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    You have put combobox 1 in twice
    I presume that this would be combobox 9 and then add combobox 13,17 and so on for subsequent races?

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: setting focus with click of command button

    The array has to list a "starting" control for each page of the Multipage.

  13. #13
    Registered User
    Join Date
    12-18-2011
    Location
    Back in Warwickshire
    MS-Off Ver
    365
    Posts
    59

    Re: setting focus with click of command button

    Thank you all who are helping with this but I am having real problems getting to grips with it. I will be returning to this problem in due course.
    Until then if i leave "race1" to the front in the editor window it automatically focuses on the combobox1

    Thankyou for your time
    Last edited by shakey775; 01-28-2012 at 01:39 AM. Reason: spelling mistake

+ 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