Solved

RunCommand problem

Posted on 1998-11-29
3
478 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
ID: 1969540
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
ID: 1969541
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
ID: 6858729
Fixed the -1 problem on this question.
Escrow points corrected.

kb
Community Support Moderator
Experts Exchange
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

815 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

12 Experts available now in Live!

Get 1:1 Help Now