You're not missing anything! The code will simply exit without setting Cancel -
thus allowing the number to be used. It might be clearer if you said:
If intResponse = vbNo Then
' Throw away the edit
Me.Undo
' Tell Access to not save the edit
Cancel = True
End If
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of dannyb
Sent: Friday, June 24, 2011 3:14 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Before Updat
I have this code in a controls before update, what I want is to warn the
operator that he is entering a number that has already been used but be able to
click yes and continue and use the same number. what I am missing is between
these lines
If intResponse = vbYes Then
Else
I have duplicate as YES duplicates OK in the table.
Private Sub MPC_Number_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
Dim rs As Object
Dim z As Variant
Dim intResponse As Integer
z = DLookup("[MPC_Number]", "[T_Components]", "Trim([MPC_Number]) = '" &
Trim(Me.[MPC_Number].Value) & "'")
If Not IsNull(z) = True Then
intResponse = MsgBox("This MPC Number has already been Entered, Would
you like to re-use this number? ", _
vbYesNo + vbQuestion, "Duplicate Number
Entered")
If intResponse = vbYes Then
*************************************
***************************************
Else
Me.Undo
Cancel = True
End If
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure MPC_Number_BeforeUpdate..."
Resume ExitProc
End Sub
------------------------------------
Yahoo! Groups Links
Jumat, 24 Juni 2011
RE: [MS_AccessPros] Before Updat
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar