Phucon-
You need Cancel = True if you want to tell Access to not save the record when the length test fails.
You do not need the Exit Sub in this case. You might need that, for example, if you had error trap code at the end of the procedure that you want to bypass if all is OK.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Aug 7, 2014, at 9:19 AM, saigonf7q5@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Hello Good morning
The Sub procedure that I have here included the "Cancel = True" and an "Exit Sub" statements. I am wondering if the "Cancel = True" and the "Exit Sub" are always necessary there and/or when they can be omitted.
Phucon
Private Sub txtEmployeeID_BeforeUpdate(Cancel As Integer)
If Len(Me.txtEmployeeID) > TempVars!tvMaxlen Or Len(Me.txtEmployeeID) < TempVars! tvMaxlen Then
MsgBox "Employee ID must be " & TempVars!tvMaxlen & " characters in length.", vbExclamation, " "
Cancel = True
End If
Exit Sub
End Sub
__._,_.___
Posted by: John Viescas <johnv@msn.com>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar