Alhakeem1977
Registered User.
- Local time
- Today, 05:14
- Joined
- Jun 24, 2017
- Messages
- 308
Hi All,
I've got a VBA code on a field called [ActualAC] it should trigger in a specific condition but the issue is, when it triggers it returns an error message and then the cursor should set focus on another field called [AccountNo], but it not setting the focus.
How can I overcome this issue? Please find below my code:
Thanks in advance!
I've got a VBA code on a field called [ActualAC] it should trigger in a specific condition but the issue is, when it triggers it returns an error message and then the cursor should set focus on another field called [AccountNo], but it not setting the focus.
How can I overcome this issue? Please find below my code:
Code:
Private Sub ActualAC_BeforeUpdate(Cancel As Integer)
On Error Resume Next
Dim strLinkCriteria As String
strLinkCriteria = "[CustTypeID] = " & Me!CustTypeID & " AND " & _
"[ActualAC] = '" & Me!ActualAC & "'"
If DCount("*", "Customerstbl", strLinkCriteria) > 0 Then
Cancel = True
Me.ActualAC.Undo
MsgBox "This customer already exists!" & vbCrLf & _
"Please type the A/C No. in the Customer's A/C field.", vbCritical, "Wrong Entry"
End If
Me.AccountNo.SetFocus
End Sub
Thanks in advance!