Consulting

Results 1 to 9 of 9

Thread: If textbox contains X run Y on button press?

  1. #1

    If textbox contains X run Y on button press?

    Hello everyone,
    I've been googling furiously for the last 40 minutes and can't figure this out. I am creating a simulation for training of a web based tool we use in my office. It is a very simple tool comprised of about 4 pages with basic buttons and prompts. I have everything working except for one piece.

    On the first page of our tool, you search for a user using a 4-digit identifier. I have a text box to type the identifier as well as a button that moves you to the next page in the tool. However, I cannot for the life of me figure out how to make the button check the identifier. We have a couple different situations that I want to show, and each would need a different identifier.

    Basically. If X is in the text box, I want the button to go to slide Y, but if Y is in the text box I want the button to go to slide Z. Does that make sense?

    Any help would be greatly appreciated.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Show us the code you have now.

    Copy the code in the VBA Editor, then in your post here, Click the # icon and then press Ctrl+V
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    I was able to get one scenario working. Here is what I did. However I now am having issues trying to create multiple scenarios. I was planning on just using ElseIf statements, but it keeps giving me errors that I'm trying to work through. Is there a more efficient way to create multiple options than with ElseIf statements?

    Sub ifthen()
     
    If Slide1.TextBox21.Value = "napr" Then
     
     
    With Application
        .Presentations(1).SlideShowSettings.Run
    With SlideShowWindows(1).View
        .GotoSlide 2
    
     
    Exit Sub
     
     
    End With
    End With
    End If

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    That's not much code for me to go on... For one thing, Where's the button?

    But here is an example of one way to make selections based on multiple options.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    It's VERY unclear what you need.

    Is this the scenario or is it something else entirely??


    A slide show is RUNNING
    There is an activX textbox the user can type a four digit number into based on the entry it jumps to a specified slide.

    If it is something else a clear explanation will help!
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    My apologies if I was unclear in what I was asking.

    I have a PowerPoint open with a screenshot of the first page of our online password reset tool. On that page there is a text entry field (where you would type in the 4-digit identifier of the user) as well as a search button.

    My first issue was trying to figure out how to make it so if I entered in a specific identifier into the text box and then hit search, it would go to a specific slide.

    I don't think what I did was very efficient, but it is working now. I used an invisible action button over the search button on the screenshot and put a text box over the spot where the user would normally type. I then worked my way through to the code I had up top. Now when I search for "NAPR" it goes to a specific slide.

    The next problem I had was how to have it go to a different specific slide when I type in something else, "Fo0d" or "CAR5" for example. I was able to get this working as well pretty quickly, however I doubt any of this was efficient. This is what my code looks like now:

    Sub ifthen()
    If UCase(Slide1.TextBox21.Text) = "FO0D" Then
     
    With Application
        .Presentations(1).SlideShowSettings.Run
    With SlideShowWindows(1).View
        .GotoSlide 2
        End With
        End With
        
        End If
       If UCase(Slide1.TextBox21.Text) = "CAR5" Then
    
    With Application
        .Presentations(1).SlideShowSettings.Run
    With SlideShowWindows(1).View
        .GotoSlide 20
        End With
        End With
        End If
    
    Exit Sub
     
     
    End Sub
    Does that clear things up a bit? Again, sorry for the confusion. I'm totally new to this whole thing and thought I was providing all necessary information.

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Much better

    Sub ifthen_by_vbaexpress() 
    Dim SlideNum As Long 'You need to verify that Slide numbers are Long Type, 'cuz I don't know.
    
    Select Case  UCase(Slide1.TextBox21.Text)
        Case "FO0D": SlideNum = 2
        Case "CARS": SlideNum = 20
        Case "TOTALNOOB": SlideNum =99
        Case "SAMT": SlideNum = 999
        Case "VBAEXPRESS.COM": SlideNum = 9999
        Case Else: Exit Sub
    End Select
             
           With Application 
                .Presentations(1).SlideShowSettings.Run 
                With SlideShowWindows(1).View 
                    .GotoSlide SlideNum 
                End With 
            End With 
         
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  8. #8
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    jumpcondition.pptm

    If you can type into an ActivX box you are ALREADY in show mode so the line .Presentations(1).SlideShowSettings.Run is not needed.

    The attached file shows how you might do this

    Right click the box > View Code to see the code which should be easy to adapt

    Test by entering ABC or XYZ in show mode and then ENTER (In the code you need CAPS I think ut you can alter this as in Sam's code
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  9. #9
    Oh my gosh that is so much cleaner and more efficient!!! Thank you so much!

Posting Permissions

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