gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,341
- Office Version
- 365
- Platform
- Windows
I’m stuck on a bit of VBA code that seems like it should be simple but everything I try is failing. I want to do an AfterUpdate event on a field where it checks if the data entered is a number, if it is then the code will format it as currency and if not it should pop-up with a warning to enter a number value, clear the field, and re-activate it. Everything is working except for re-activating the field, it keeps moving to the next one.
Code:
Private Sub Field1_AfterUpdate()
With Field1
If IsNumeric(.Value) = True Then
.Value = FormatCurrency(.Value, 2, vbTrue, vbTrue, vbTrue)
ElseIf .Value = "" Then
.Value = FormatCurrency(0, 2, vbTrue, vbTrue, vbTrue)
Else
MsgBox "Enter a number value"
.Value = ""
.SetFocus
End If
End With
End Sub
[code/]
thanks