Solved

RunCommand problem

Posted on 1998-11-29
3
454 Views
Last Modified: 2010-08-05
Hi, I saved a record using the RunCommand macro using a customized toolbar command.  Now I want to add a new record using a customized "New Record" toolabr command.  However, when I try to do so after I click on my "Save Record" toolbar button , I get an error: "The RunCommand action was cancelled."  Can you tell how to fix this?

TIA,
Darryl
0
Comment
Question by:dbSystems
3 Comments
 

Expert Comment

by:marrip
Comment Utility
Are you using a macro or VBA code to send the command to your toolbar item. If you are using VBA code are you trapping for any errors?
0
 
LVL 10

Accepted Solution

by:
brewdog earned 50 total points
Comment Utility
I don't know if you ever looked back at this, dbSystems. I'll expand on marrip's suggestion. Instead of using a macro, go to the Module tab of your database and either create a new module or open an existing one. Use this sub:

Public Sub SaveRecord ()

   on error goto SaveError
   DoCmd.RunCommand acCmdSaveRecord
   Exit Sub

SaveError:
   select case err.number
       case 3022                  'duplicate in primary key
          msgbox "This entry already exists. Please change your entry."
          exit sub
       case else
          msgbox "Error #" & err.number & ", " & err.description, vbInformation, "Unexpected Error . . ."
          exit sub
    end select

end sub

Hope that helps . . .

brewdog
0
 
LVL 1

Expert Comment

by:kodiakbear
Comment Utility
Fixed the -1 problem on this question.
Escrow points corrected.

kb
Community Support Moderator
Experts Exchange
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now