+ Reply to Thread
Results 1 to 6 of 6

Issues with setting focus on Userform

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Issues with setting focus on Userform

    Hi,

    I have a userform that is called by clicking on a button and it copies the value in cell A to my userform. This works great it is called via:

    Please Login or Register  to view this content.
    However, when using this method for some reason another peice of code that I have on a userform that pops up from the first does not see 'FmNAS' as visible. I am using a calendar form and instead of updating the value on the userform it updates the active cell.

    Is there a way the code above can set the focus on the userform rather than the active cell? The spreadsheet is very large so I cannot post an example.

    Thank you in advance
    Last edited by jpruffle; 07-07-2009 at 03:17 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issues with setting focus on Userform

    That's not a question of focus, it's just that the code is wrong (are you using Selection?) It would be helpful to see the code on the calendar form that returns the value.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Issues with setting focus on Userform

    Thank you for the quick reply.

    When the calendar date is selected the following code is used:

    Please Login or Register  to view this content.
    This is the same for all dates. Instead of putting the data into 'nascreation' for example it puts it onto the active cell. I'm assuming something needs adding to the first code to make the FmNAS active in some way.

    This form and the calendar works fine when not called by the code shown on the first thread.

    Thank you again

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issues with setting focus on Userform

    Hello jpruffle,

    The code you have (shown below) creates a New Instance of the UserForm. That is not what you want to do. You need to set an Object Variable to the UserForm. The reason you can't show frm is because it has not been added to the UserForms collection.
    Please Login or Register  to view this content.
    Change your code to this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issues with setting focus on Userform

    Are you loading the calendar from fmNas? If so, what code are you using for that?

  6. #6
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Issues with setting focus on Userform

    Thank you both very much for your help.

    Leith Ross that worked perfectly and thank you for the explanation.

+ 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