help with userform

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
Hi All

I have a userform and I want to make sure that the contents of a textbox doesnt contain either a 0 or an empy ("") value.

I am checking this on Initialization, OnChange and OnExit. It works ok apart from the part that resets the focus to the textbox that I want to user to complete. On Exiting the textbox, it runs through the code and executes the line setting the focus, but when it come to the end of the code (End Sub), the cursor goes to back to the textbox that the user click into when they exited the textbox that requires the value.

Obviously no geeting this to work could mean that the values won't be present when it comes to do the required calculations!

My code for the Exit is:
Code:
Private Sub txtProgressCostPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    If frmCalculatePrice.txtProgressCostPrice = 0 Or frmCalculatePrice.txtProgressCostPrice = "" Then
        MsgBox "You must enter a COST PRICE for this product"
        frmCalculatePrice.txtProgressCostPrice.Enabled = True
        frmCalculatePrice.txtProgressCostPrice.SetFocus
    Else
        frmCalculatePrice.txtProgressCostPrice = FormatCurrency(txtProgressCostPrice, -1)
        frmCalculatePrice.txtProgressCostPrice.Enabled = False
    End If
End Sub

Does anyone know what I am doing wrong or can help!

Kindest Regards

Peter
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Thanks

How do I set the cancel paremeter to true please?

Kindest Regards

Peter
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

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