Solved

RunCommand problem

Posted on 1998-11-29
3
498 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
[X]
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
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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