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 / General 2 / September 2007

Tip: Looking for answers? Try searching our database.

if error msg then

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deb - 17 Sep 2007 20:00 GMT
I have a form that enters schedule images.

If user tries to enter a duplicate, I would like to display a warning msg
and give options to proceed.

How should this be written?

if error 3022- The changes you requested to the table were not successful
because they would create duplicate values in the index, primary key, or
relationship.  Change the data in the field or fields that contain duplicate
data, remove the index, or redefine the index.

Then...

Msg = "Warning Schedule Image for selected Report Date and Page was
previously entered." _
            & vbCr & vbCr & "Yes, to be directed to the original record." _
            & vbCr & "No, to delete current record." _
            & vbCr & "Cancel, to make changes to current record."
       ans = MsgBox(Msg, vbYesNoCancel)
       
       If ans = vbNo Then
           Me.Undo
           DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
           DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
           DoCmd.GoToRecord , , acNewRec
            MsgBox "Duplicate Deleted."
            Exit Sub
   
       ElseIf ans = vbYes Then
           Me.Undo
           'Go to record of original ID
           rsc.FindFirst stLinkCriteria
           Me.Bookmark = rsc.Bookmark
           Exit Sub
      End If

Thanks in advance,
Signature

deb

Larry Daugherty - 17 Sep 2007 21:21 GMT
You need Error Handlers.  They trap errors and take action that you
code.  Within the Error Handler for a given procedure you can use a
Select -- Case statement to fine tune responses to some specific
errors while letting all others fall through to your default response.

There are some 3rd party tools that can help you along with the
process.  MZTools is the first that comes to mind.  It's a free
download and it's very powerful.  There *should be* an Error Handler
in every procedure.

HTH
Signature

-Larry-
--

> I have a form that enters schedule images.
>
[quoted text clipped - 34 lines]
>
> Thanks in advance,
 
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



©2009 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.