Results 1 to 3 of 3

Thread: Problem with the Exit button in combination with txt_lostfocus event.

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    bangalore
    Posts
    2

    Problem with the Exit button in combination with txt_lostfocus event.

    On a form i have a button to exit the form.
    I have also several text controls on the form.
    I have embeded validation code for the lostfocus event of the text controls.

    My question is Is How can i bypass the evaluation of the code written within the text_lostfocus sub procedure when I click on the exit button.

    Kindly indicate a suitable alternate method if the present approach is not feasible.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Use something like a cancel button, then in the LostFocus event, put
    VB Code:
    1. If Not (ActiveControl Is cmdCancel) Then
    2.                   With Text1
    3.                      'Perform data validation
    4.                   End With
    5.             End If

  3. #3
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Albany, NY
    Posts
    489
    I had a similar problem.
    there is no way to evaluate what the user clicked
    to cause the LostFocus Event so you can't determine
    whether the exit button is clicked. as a workaround
    I evaluated the the Text Controls on the GotFocus event
    by error checking the Text Control with the TabIndex prior
    to the one getting focuss. did that make sense??

    Example
    VB Code:
    1. Private Sub Text2_GotFocus()
    2. If Me.Text1.Text = "" Then
    3.     MsgBox ("Enter a value for Text1")
    4. End If
    5. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width