xyxex (TechnicalUser) 19 Mar 09 7:51
I have a piece of code that checks a value entered in a textbox is numeric.
Private Sub txtTargetInc_Change()
If HasNumber(txtTargetInc) = True Or txtTargetInc = "" Then GoTo OUT
numerror
OUT:
End Sub
I want to re-use this code for all numeric fields by bringing the control name into the procedure as a variable
I have attempted this below but I cannot figure out the syntax for it to work.
Can anyone help?
Textbox is the name of the tetxtbox that i want to test contents of
Private Sub ErrChk(TextBoxName As String)
With Me.Controls(TextBoxName)
If IsNumber(TextBoxName) = True Or .Value = "" Then GoTo oUT
.Value = "0"
numerror ' Calls msgbox
End With
oUT:
PopulateClmLoad
End Sub
Private Sub txtTargetInc_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ErrChk (txtTargetInc)
If txtTargetInc = "" Then GoTo oUT
Range("expprem7").Value = Range("expprem").Value * (1 + Range("TargetInc").Value / 100)
expprem7.Value = Format(Range("expprem7").Value, "£#,###.00")
Adj1.Value = Format(Range("adjq1").Value, "0.00%")
Adj2.Value = Format(Range("adjq2").Value, "0.00%")
Adj3.Value = Format(Range("adjq3").Value, "0.00%")
Adj4.Value = Format(Range("adjq4").Value, "0.00%")
txtuwadjsumm.Value = Format(Range"TotUWadj1").Value, "0.00")
oUT:
End Sub
I have a piece of code that checks a value entered in a textbox is numeric.
Private Sub txtTargetInc_Change()
If HasNumber(txtTargetInc) = True Or txtTargetInc = "" Then GoTo OUT
numerror
OUT:
End Sub
I want to re-use this code for all numeric fields by bringing the control name into the procedure as a variable
I have attempted this below but I cannot figure out the syntax for it to work.
Can anyone help?
Textbox is the name of the tetxtbox that i want to test contents of
Private Sub ErrChk(TextBoxName As String)
With Me.Controls(TextBoxName)
If IsNumber(TextBoxName) = True Or .Value = "" Then GoTo oUT
.Value = "0"
numerror ' Calls msgbox
End With
oUT:
PopulateClmLoad
End Sub
Private Sub txtTargetInc_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ErrChk (txtTargetInc)
If txtTargetInc = "" Then GoTo oUT
Range("expprem7").Value = Range("expprem").Value * (1 + Range("TargetInc").Value / 100)
expprem7.Value = Format(Range("expprem7").Value, "£#,###.00")
Adj1.Value = Format(Range("adjq1").Value, "0.00%")
Adj2.Value = Format(Range("adjq2").Value, "0.00%")
Adj3.Value = Format(Range("adjq3").Value, "0.00%")
Adj4.Value = Format(Range("adjq4").Value, "0.00%")
txtuwadjsumm.Value = Format(Range"TotUWadj1").Value, "0.00")
oUT:
End Sub