Researcher
I.T. Veteran
- Local time
- Yesterday, 18:37
- Joined
- Oct 11, 2006
- Messages
- 42
Im attempting to validate an amount field to control the currency that is entered. The data type is currency and the code appears to work fine, however I would like to setfocus to the amount field if the currency entered is 0 or above 200,000. Everything I have tried gives me back the error:
Run-Time error '2108':
You must save the field before you can execute the GoToControl Action, the GoToControl Method, or The SetFocus Method.
Can someone tell me what I am doing wrong? I have attached the code below:
Private Sub Amount_BeforeUpdate(Cancel As Integer)
Dim stramt As String
Dim strtop As String
Dim amtname As String
stramt = "0"
strtop = "200000"
amtname = Amount.Text
If Me.Amount = stramt Then
MsgBox "Jackpot amounts must be greater than zero", vbInformation
Me.Controls(Amount).SetFocus
End If
If Me.Amount > strtop Then
MsgBox "Jackpot amounts are less then 200,000", vbInformation
Me.Controls(Amount).SetFocus
End If
End Sub
Run-Time error '2108':
You must save the field before you can execute the GoToControl Action, the GoToControl Method, or The SetFocus Method.
Can someone tell me what I am doing wrong? I have attached the code below:
Private Sub Amount_BeforeUpdate(Cancel As Integer)
Dim stramt As String
Dim strtop As String
Dim amtname As String
stramt = "0"
strtop = "200000"
amtname = Amount.Text
If Me.Amount = stramt Then
MsgBox "Jackpot amounts must be greater than zero", vbInformation
Me.Controls(Amount).SetFocus
End If
If Me.Amount > strtop Then
MsgBox "Jackpot amounts are less then 200,000", vbInformation
Me.Controls(Amount).SetFocus
End If
End Sub