I have a textbox named "txtEndBalance" in a form I want only numbers to be inserted as a part of data validation. Therefore I have On Error event.
Now when I fire up the form via a button. It directly goes to the error and I have a message box pop up "Invalid currency amount". This wasn't supposed to be like this.
And then when I get rid of the pop up trying to enter a number. And right when I enter a single digit number it throws that error again.
I have no idea where I am wrong in the code below because I think I did everything right.
Have look at the file here if you need.
Private Sub txtEndBalance_Change()
On Error GoTo Error:
Dim amt As Currency
amt = txtEndBalance
txtEndBalance = Format(amt, "$##,###,##0")
Exit Sub
Error:
If txtEndBalance <> "$" And txtEndBalance <> "" Then
MsgBox "Invalid currency amount", , "Error"
txtEndBalance = Format(0, "$##,###,##0")
End If
End Sub