Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2011
    Posts
    3

    Unanswered: VBA help... How to stay on current textbox

    Hi all,

    I have a textbox that checks where the value entered (in this case Year) is in the past, present or future.

    If it is in the past a msgbox appears, The users will click OK, but the cursor goes to the next textbox, rather then staying on the textbox that needs to be corrected.

    Any ideas on how to stay on the textbox?

    Thanks

    Halil

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use the setfocus function in the code that handles the message box.
    alternatively redesign your code to include a date picker that doesn't allow the users to choose an invalid date
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2011
    Posts
    3
    Hi,

    I've added it but still no go

    Code:
                If txtStartDate.Text < iYear Then
                    MsgBox "Please enter a year that is not in the past", vbCritical, "Please enter Year..."
                    frmCityDev.txtStartDate.SetFocus
    
                End If
    It still goes to the next textbox.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •