Solved

Access  - Run-time error 2501 RunCommand canceled.

Posted on 2013-01-19
11
1,097 Views
Last Modified: 2013-01-19
Hello all

I have a tabbed form that when I Select a Location and then click a Command Button it is supposed to create a set number of records for input by the user.

If I F9 the first line of that Command Buttons code and F8 to step thru it it all works....

However if I get rid of the F9 on that first line and just let the code run it errors and gives me the
Run-Time error 2501
RunComman action was canceled...

I am attaching a generic version of the db so you can see it for yourself.....

The form to open is [tfrm_Reporting]

There is ONE highlighted combobox field to select a location name.  (there's only one)  select it and click the Command Button right beside it captioned "Create Input Form"

that is when it is to create the exact number of records I want input.
Test-Continuous-Cycle-Records.accdb
0
Comment
Question by:wlwebb
  • 5
  • 4
  • 2
11 Comments
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 200 total points
ID: 38797256
Try changing that portion of the code - using recordset code:

        Dim rs As DAO.Recordset
    ' **** AMTOut ****
        Me.[tsfrm_dta_TransactDetails_AmtOut].Form.Visible = True
        With Me.[tsfrm_dta_TransactDetails_AmtOut]
            Set rs = .Form.RecordsetClone
            
            .Visible = True
            
           ' DoCmd.RunCommand acCmdRecordsGoToNew
           
            For j = j To lngNbrMachs
                rs.AddNew
                rs![MachNbr] = j
                rs![TransactTypeID] = 2
                rs![TransactAmt] = 0
                rs!ReportingID = Me.ReportingID
                rs.Update
            Next
            rs.Close
            .Form.Requery
            .SetFocus
            '.Form.AllowAdditions = False
        End With
    

Open in new window


It looks like there are issues with later parts of your code as well - so try to isolate this part and test it before moving on to the next.
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 300 total points
ID: 38797287
Here you go.  I revised your code a bit.  As an aside, it looks like you're still making use of LookUp fields in your tables.  You really would be better off without them as I mentioned before.
Test-Continuous-Cycle-Records.accdb
0
 

Author Comment

by:wlwebb
ID: 38797304
Irog.......

Looking at the code I think you are doing what MBiz was suggesting...... Am I right in that?????  

As you and MBiz have helped a lot in the past you know I am very very limited in what I understand to this point.
0
 

Author Comment

by:wlwebb
ID: 38797305
Oh.... AND WOW is that a lot faster loading....!!!!!!
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38797308
I need to correct myself.  It was someone else I advised about not using Lookup fields.  So in case no one has mentioned this yet, let me just paste a bit of what I posted in another question.

Lookup Fields --  why oh why did Microsoft add this feature!
I cannot emphasize enough the magnitude of avoiding using Lookup Fields in your table.  It's purpose was to make it supposedly easy for a novice to work with related tables.  However, it causes more problems than it solves and I think it actually makes it more confusing for those trying to grasp the concept of relational tables.  

Every newcomer to Access read and heed this article:
The Evils of Lookup Fields in Tables    Adding one more bullet to the list in this article is the inability of Child and Master fields to link properly if one of the fields is a Lookup field.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 29

Expert Comment

by:IrogSinta
ID: 38797318
I saw Miriam's code after I posted but you're right about them being pretty much the same.  That's because great minds think alike :-)
Mine just has a nested loop so that it covers all 3 transaction types.
0
 

Author Comment

by:wlwebb
ID: 38797321
By lookup fields in my tables you are specifically referring to the Lookup tab on the table setup where my SELECT statement is correct???????????

And by the way................for You and for Mbiz........

I'm just now seeing what you guys meant by using the With statements a while back.......... I'm a might bit slow I guess.... Now this rst stuff............  whew ......... ;-))))
0
 

Author Comment

by:wlwebb
ID: 38797323
Is the DAO stuff that much faster than all this other code????
0
 

Author Closing Comment

by:wlwebb
ID: 38797354
I split the points as both of you made the same suggestion but Irog actually put it in my db.....
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38797460
I've never benchmarked it but I'm almost certain that looping through a Dao recordeset would be faster than the form based approach, which involves the bulk of the user interface.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38797462
You're right about the lookup tab in your table design.  Avoid that like the plague.  :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

863 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

24 Experts available now in Live!

Get 1:1 Help Now