Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Help Exiting vbYes/No Msgbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
poucedeleon - 27 May 2008 13:19 GMT
I add this to my form to catch duplicate entries. It catches the dupilcate
entries but if I click "No" to "Cancel" it doesn't do anything. I am stuck on
the record unless I click "Yes" Should there be another If Statement in the
code?

**************************** Code********************************************
Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tlkpStaff", "StaffLastName = """ & Me!StaffLastName & """ And
StaffFirstName = """ & Me!StaffFirstName & """") > 0 Then
       If MsgBox("There is already a staff member by this name in table. Do
you wish to add it anyway?", vbYesNo) = vbNo Then
           Cancel = True
         End If
       End If
End Sub
Beetle - 27 May 2008 15:11 GMT
Try adding an Undo after the cancel.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tlkpStaff", "StaffLastName = """ & Me!StaffLastName & """ And
StaffFirstName = """ & Me!StaffFirstName & """") > 0 Then
       If MsgBox("There is already a staff member by this name in table. Do
you wish to add it anyway?", vbYesNo) = vbNo Then
           Cancel = True
           Me.Undo
         End If
       End If
End Sub

Signature

_________

Sean Bailey

> I add this to my form to catch duplicate entries. It catches the dupilcate
> entries but if I click "No" to "Cancel" it doesn't do anything. I am stuck on
[quoted text clipped - 11 lines]
>         End If
> End Sub
poucedeleon - 28 May 2008 09:54 GMT
Thanks Beetle, That fixed it.

>Try adding an Undo after the cancel.
>
[quoted text clipped - 14 lines]
>>         End If
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.