+ Reply to Thread
Results 1 to 9 of 9

Form: texbox navigation

  1. #1
    Registered User
    Join Date
    07-03-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Form: texbox navigation

    I have a form set up with excel (2003) using vba. I'm doing a check to see if textbox1 is empty, if it is, a msgbox pops up with a warning that "textbox1 needs to be filled out". I click OK and the cursor goes to textbox2. I want the cursor to return to texbox1 without user intervention but can't figure out how. I'm using "Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)".
    I know it can be done because I did it with vba Access, but I can't seem to find it using vba Excel. Any help would be appreciated.
    Last edited by nglow; 07-04-2009 at 08:56 AM.

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

    Re: Form: texbox navigation

    You need to set focus to the control

    Please Login or Register  to view this content.
    Please use code tags when post any code.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    07-03-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Form: texbox navigation

    I tried textbox1.setfocus that but it didn't work. it still went to textbox2.

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

    Re: Form: texbox navigation

    Can you post your workbook?

  5. #5
    Registered User
    Join Date
    07-03-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Form: texbox navigation

    The main workbook is at work, but I just created a simple form with 2 textboxes to test.
    this is the code I'm testing

    Please Login or Register  to view this content.
    Last edited by nglow; 07-04-2009 at 08:47 AM.

  6. #6
    Registered User
    Join Date
    07-03-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Form: texbox navigation SOLUTION FOUND

    I found that instead of textbox1.setfocus....you have to use:

    Cancel = True

    This worked.....

    Thanks

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form: texbox navigation

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

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

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    07-03-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Form: texbox navigation

    Thank you. I'm new and neglected to read the rules. I read then now.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Form: texbox navigation

    Thanks for taking the time to read and comply with the rule .

+ 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