Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel = True
I tried to use Cancel = Ture (as shown below) to ensure the user inputs a
value in 10 textboxes (namely txtCatchment1, txtCatchment2, ..., txtCatchment10). But my attempt returns an error at the line "Cancel=True". How should I fix this? ' Below is in UserForm1 ' (duplicate 10 times with the number changed to match the textbox name) Private Sub txtCatchment1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) CheckInput(1) End Sub ' Below is in Module1 Sub CheckInput(CatchmentNo As Long) Dim strCatchmentNo As String With UserForm1 strCatchmentNo = .Controls("txtCatchment" & CatchmentNo).Value If Len(strCatchmentNo) 0 Then Else Cancel = True MsgBox "You must enter a value", vbOKOnly + vbExclamation, "Entry Required" End If End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel = True
You're setting Cancel in a sub which has no reference to it: it's not a
global variable. Tim "Sam Kuo" wrote in message ... I tried to use Cancel = Ture (as shown below) to ensure the user inputs a value in 10 textboxes (namely txtCatchment1, txtCatchment2, ..., txtCatchment10). But my attempt returns an error at the line "Cancel=True". How should I fix this? ' Below is in UserForm1 ' (duplicate 10 times with the number changed to match the textbox name) Private Sub txtCatchment1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) CheckInput(1) End Sub ' Below is in Module1 Sub CheckInput(CatchmentNo As Long) Dim strCatchmentNo As String With UserForm1 strCatchmentNo = .Controls("txtCatchment" & CatchmentNo).Value If Len(strCatchmentNo) 0 Then Else Cancel = True MsgBox "You must enter a value", vbOKOnly + vbExclamation, "Entry Required" End If End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cancel = True | Excel Programming | |||
why doesnt cancel=true always work? | Excel Programming | |||
Another way to suppress print besides Cancel = True? | Excel Programming | |||
BeforeDoubleClick Cancel=True not working | Excel Programming | |||
Setting Cancel = True in WorkbookBeforePrint | Excel Programming |