Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

RunCommand problem

Posted on 1998-11-29
3
488 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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