+ Reply to Thread
Results 1 to 4 of 4

GotFocus event for Frames

  1. #1
    Registered User
    Join Date
    10-25-2007
    Posts
    35

    GotFocus event for Frames

    I'm trying to refresh a section of a userform once a sub has run.

    My code looks something like this:

    Private Sub CommandButton1_Click()
    Lots of code
    Frame1.SetFocus
    End Sub

    Private Sub Frame1_Enter()
    Code to reset everything in this frame
    End Sub

    However, this method isn't working because the Enter event behaves differently to the GotFocus event. Unfortunately, VBA won't let me use GotFocus for a frame.

    Short of integrating the code to refresh the frame into my CommandButton sub (which I don't really want to do as I would actually need to paste it a few times, thereby lengthening my code) does anyone have a solution?

    Thanks a million.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    Rather than place the code in the command button event and elsewhere, place it in a routine and call that from the button click and frame enter routines.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    Cheers Andy,

    To the rescue as ever. Is it standard practice to use the Call statement for Control events? Until now I've just been putting all my code in the event procedure.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Please add the Code Tags as requested
    Hope that helps.

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

    Free DataBaseForm example

+ 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. Run-Time Error 91 When Dynamically Creating Controls and Event Handlers
    By chucklod in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2008, 05:47 PM
  2. VBE activate event
    By digita in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-28-2007, 10:47 PM
  3. Exit event issues
    By vlado_solo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-28-2007, 07:47 AM
  4. BeforeDoubleClick Event on Protected Sheet
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2007, 09:12 PM
  5. Flagging event due dates
    By muskt in forum Excel General
    Replies: 7
    Last Post: 11-19-2006, 05:44 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