Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Execute If Statement on Textbox GotFocus (2003)

    Hi, I am breaking my head trying to figure how can I make an If statement to check the condition of a textbox and execute an statement that will change the caption "Current Position" on a label to " Phone Number" . Below is what i am working on

    Private Sub Form_Current ()

    If Me!txtSearchInfo.SetFocus Then
    Me!Label32.Caption = "Phone Number"
    Else
    Me!Label32.Caption = "Current Position"
    End If

    End Sub

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    I'm sure I've misunderstood, but why not use the On Got Focus event for the textbox control?
    Silverback
    Silverback

  3. #3
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    I have to difference search fields; one that search names and ssn, the other phone numbers with one list box that displays the info in accordance to what the user is requesting, I wanted to make the caption of the list box to change depending what search is used and get back to its default caption. At the present moment I included the caption change in different control procedures to make the effect of just having the code execute from one procedure.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    Do you know which search is happening? If so, one way might be to have two list boxes and labels, one exactly on top the other and when you have deduced which search is happening, make one list box and label visible and leave the other pair invisible.
    Would that solve the problem?
    Silverback
    Silverback

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    SetFocus is a method that does something, it is not a property that returns a value.

    You'll have to keep on using event procedures for the two search boxes...

  6. #6
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    Thanks you all. Hans, Is there a way to initiate an if statement depending on a field status other than IsNull, Not IsNull like active or inactive. By the way, Silverback, I did not think about making two set of list and caption to be visible depending the selection, thank great idea!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Execute If Statement on Textbox GotFocus (2003)

    You can use the On Enter or On Got Focus event to react to the user moving to a control. Or do you mean something else?

Posting Permissions

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