Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

VBA SetFocus in PowerPoint

Hi Experts,

Within a PowerPoint slide, I placed 2 textboxes.  When the presenter types in a value, I would like to validate it before they move forward and regain focus to the textbox if invalid, using the code below., but I keep getting invalid use of property.

I've tried setting focus to the second textbox first, among other things as you'll see, but no luck...

Option Explicit

Private Sub txtCount_LostFocus()

    Dim strVal As String
    
    strVal = txtCount.Text
    If (IsNumeric(strVal) = False) Then
    
        MsgBox ("Please enter a valid number.")
        txtCountHidden.SetFocus
        Me.txtCount.SetFocus
        'docmd.cancelevent
    Else
        
        txtCount.Text = FormatNumber(strVal)
        txtCountHidden.Text = strVal
        
    End If
    

End Sub

Open in new window


Any help will be appreciate it.
SOLUTION
Avatar of Bembi
Bembi
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial