Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RunCommand problem

Posted on 1998-11-29
3
Medium Priority
?
535 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 200 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

610 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