+ Reply to Thread
Results 1 to 3 of 3

Weird Textbox_Exit procedure behaviour

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    201

    Weird Textbox_Exit procedure behaviour

    I have a form with a couple of controls on it including a frame. In this frame is a couple of textboxes where the user must enter some dates. I want to add error checking to this textboxes to make sure an incorrect/invalid date is not entered. I wanted to add error checking to the Control_Exit procedure to check for incorrect/invalid dates.

    Problem: If I click in any one of the textboxes (all blank at this stage) other than the first textbox in the frame the first textbox Exit procedure is run and then the procedure crashes because there is no valid date in the first textbox. I can't even get to my error checking as it crashes before that (Runtime error 13. Type mismatch.). Even though this textbox was not selected at all

    I tried changing the tabindex of the controls to make another textbox the first one and then it crashes on the new first textbox

    Any idea why this is happening? Why would the Control_Exit procedure run without the control being selected first?

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Weird Textbox_Exit procedure behaviour

    A Frame control is a container and behaves the same way a userform or other container does - as soon as you set focus to it, the control with the lowest tab index gets the focus. So when you click another textbox, you set focus to the frame first, which sets focus to the first textbox and then the focus moves to the control you actually clicked.

    With all that said, your code should be checking for an empty control first.

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Weird Textbox_Exit procedure behaviour

    That explains a lot. Thank you.

+ 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. [SOLVED] Weird behaviour of column copy
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2015, 11:50 AM
  2. [SOLVED] Weird Filepath Behaviour
    By timbo1957 in forum Excel General
    Replies: 1
    Last Post: 08-05-2012, 04:56 PM
  3. Weird behaviour of the BeforeSave procedure when fired by Me.Save
    By mach128x in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2011, 09:08 PM
  4. Weird behaviour for a basic sum
    By barid in forum Excel General
    Replies: 3
    Last Post: 08-27-2009, 07:38 AM
  5. Weird Button Behaviour
    By roasty_1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2008, 04:34 AM
  6. [SOLVED] Excel2000: Weird behaviour in VBA
    By Arvi Laanemets in forum Excel General
    Replies: 3
    Last Post: 02-01-2006, 10:14 AM
  7. Weird Cell Behaviour
    By Matt in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-18-2005, 02:05 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