Error when userform textbox value is empty

Prevost

Board Regular
Joined
Jan 23, 2014
Messages
198
Hi,
I have a userform with 2 textboxes that a user can enter values in. When I step through the code, WOQty is "0" and WONo is "" even when the textboxes have values entered into them. I declared 'Public WOQty as Integer' and 'Public WONo as String' in my UserForm and then tried in a Module and I still get the same error. Any ideas?
Thanks!

Code:
Private Sub OK_Click()
    WOQty = Me.TextBox1.Text
    WONo = Me.TextBox2.Text
    If IsEmpty(WONo) = True Then
        MsgBox ("Please Enter A Work Order Number")
        boolrestart = True
    ElseIf IsNumeric(WOQty) = False Then
        MsgBox ("Please Enter A Numeric Quantity")
        boolrestart = True
    ElseIf IsEmpty(WOQty) = True Then
        MsgBox ("Please Enter A Work Order Quantity")
    Else
        Worksheets("Template").Unprotect Password:=""
        WOEntry.Hide
        i = 1
        SheetName = WONo & "-" & i
        Sheets("Template").Copy After:=Sheets(1)
        ActiveSheet.Name = SheetName
        Call Create_Button
        Worksheets("Template").Protect Password:=""
        Worksheets(SheetName).Unprotect Password:=""
    End If
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Thanks Mike. It still does not recognize anything that is entered in the textbox...I am not sure what is going on. I did have it working before using the code below, but I do not want the code to check for any changes in the textbox.

Code:
Private Sub TextBox1_Change()

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top