none
RunCommand acCmdRecordsGoToNew produces error 2501: RunCommand action was canceled

    Question

  • New to a Splitform and the RunCommand acCmdRecordsGoToNew produces error 2501: RunCommand action was canceled

    Any tips?

    I've tried adding both ...

            RunCommand acCmdRecordsGoToFirst
            RunCommand acCmdSave

    Thanks in advance

    Curtis


    Curtis Wayne

    Friday, February 10, 2012 10:34 PM

Answers

All replies

  • Can this work for you?

        DoCmd.GoToRecord , Me.Name, acNewRec


    Chris Ward

    Friday, February 10, 2012 10:38 PM
  • I tried that & got a similar error, i.e. Cannot go to record etc.

    Plus I was trying to move away from DoCmd for some reason (can't recall precisely right now), but I think I read somewhere it was going away in the newer versions of Access.  I am working with Access2007 BTW, in case it matters.

    BUT, I added Save & a Form ReQuery just prior to the GoToRecord and all is well.

    The crux is the ReQuery I believe.  Because I already tried a Save, MoveLast, MoveFirst (all together) etc.

    Being new to the Split Form View, I am guessing the form recordset and underlying data source are not synchronizing until I force  the ReQuery.  That's just a hunch.

    Any Split Form View pointers would be HUGELY appreciated, i.e. are serious / experienced developers using Split Form much?  Split Form vs Subforms etc.

    Thanks!


    Curtis Wayne

    Saturday, February 11, 2012 8:26 PM
  • Hi Curtis,

    Thank you for posting.

    What is the version of your access applicaition? Can you share us a copy of the database on the skydirve:

    http://www.skydrive.com and reproducible steps list so that I can reproduce it on my side? I found that there are some other people who also encountered the problem:

    http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/1f3712db-f745-4453-b4b5-24528edfb01c
    http://dbaspot.com/ms-access/155663-access-2007-bug-focus-does-not-stay-new-record-code.html

    If it is indeed be reproduced it on my side, I will help you submit to our product team.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    Friday, February 17, 2012 7:36 AM
  • Our parent company has a block on using sites like SkyDrive due to them being categorized as File Storage sites.  I'll check into that.  I can certain email you a copy, if that'll work.

    Here is the code in a command button in the detail section of my Split Form (adding the Me.Requery eliminates the error:  Can't go to specified record #2105)

    Private Sub cmdAddNewTime_Click()
        On Error GoTo err_cmdAddNewTime_Click
        If Not Me.EmployeeSelected Then
            MsgBox "Please select employee 1st.", vbCritical, "Add New Time"
            Me.cboFilterEmployee.SetFocus
            Me.cboFilterEmployee.Dropdown
        Else
            ' BEFORE adding a new time entry ...
            ' 1. save the current time information
            ' 2. execute the form's Requery method to force an explicit retrieval of underlying recordset changes
            '    (synchronizes Split Form view with new data)
           
            Me.SaveTime ' SaveTime is my own Function / Method - see above
           
            '
            ' These commands I inserted in an effort to eliminate the error ...
            '
            'RunCommand acCmdRecordsGoToFirst
            'RunCommand acCmdRecordsGoToNew
            'DoCmd.GoToRecord , , acLast
            'DoCmd.GoToRecord , , acFirst
           
            '
            ' This command eliminates the error ...
            '
            'Me.Requery
           
            Me.cboWorkOrder.SetFocus
            DoCmd.GoToRecord , , acNewRec
            Me.EmployeeID = Me.cboFilterEmployee
            Me.cboWorkOrder.SetFocus
            Me.cboWorkOrder.Dropdown
        End If
    exit_cmdAddNewTime_Click:
        Exit Sub
    err_cmdAddNewTime_Click:
        MsgBox "Error:  " & Err.Description & vbCrLf & "#" & Err.Number, vbExclamation, "Add New Time"
        Resume exit_cmdAddNewTime_Click
    End Sub

    Here is my SaveTime Function ...

    Public Function SaveTime() As Boolean
        On Error GoTo err_SaveTime
        If Me.Dirty Then
            If Me.EmployeeSelected Then
                '
                ' ??? Not quite sure how this works (borrowed from another developer online) ...
                '
                Me.Dirty = False    'Saves any edits. COOL!
                ' Alternate save approach ...
                ' RunCommand acCmdSave
            Else
                Me.Undo
            End If
        End If
        SaveTime = True
    exit_SaveTime:
        Exit Function
    err_SaveTime:
        MsgBox "Error:  " & Err.Description & vbCrLf & "# " & Err.Number, vbCritical, "Save Time"
        SaveTime = False
        Resume exit_SaveTime
    End Function

    I hope this gets us started.  Unfortunately, I won't be back until Monday 2/17/12.

    Thanks in Advance - and I'll consult our network admin about SkyDrive next week.  I do have access to YouSendIt though, if that helps at all.

    Your assistance is greatly appreciated.

    Curtis


    Curtis Wayne

    • Proposed as answer by Bruce Song Tuesday, February 21, 2012 6:54 AM
    • Unproposed as answer by Curtis Wayne Tuesday, February 21, 2012 10:29 PM
    Friday, February 17, 2012 10:27 PM
  • I pressed send on the last email w/ my code before I realized I never answered what version.  I am working with Access 2007 SP2.

    Thanks,

    Curtis


    Curtis Wayne

    Friday, February 17, 2012 10:31 PM
  • Hi Curtis Wayne,

    Seems that you have got a workaround about the problem by using Me.Requery. Did you still need any assistant about this problem? I am not very sure whether this can help you:

    http://office.microsoft.com/client/helppreview14.aspx?AssetId=HV080201830&lcid=1033&NS=MSACCESS%2EDEV&Version=14&tl=2&queryid=&respos=1&HelpID=vbaac10%2Echm13503

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Curtis Wayne Thursday, March 15, 2012 5:22 PM
    Tuesday, February 21, 2012 6:58 AM
  • Me.Requery does eliminate the error.  The error was resulting from saving the new records and immediately issueing DoCmd.GoToRecord , , acNewRec

    I'd like to better understand why the Requery is required and a save command alone does not. 

    I wonder if the Requery is necessary due to the form being filtered.  I am using the form's .Filter property, driven by an unbound combo box containing employees, to control the currently displayed records.  So the the form's recordset is constantly filtered.  In a nutshell, the user needs to repeatedly add multiple entries for the currently selected employee, before moving on to the next employee.

    BTW - the hyperlinked document from the Access 2010 Developer Reference titled Form.Requery Method (Access) did hit on this:

    "The Requery method ... Updates records displayed based on any changes to the Filter property of the form."

    When I create a new record I am not altering the Filter itself.  Rather, I am altering the underlying recordset being filtered.  I guess RunCommand acCmdSave does not trigger any refreshing of the form recordset.  Possibly adding a new record when the underlying recordset does not match the form recordset causes the error?  QUESTIONS:  Does DoCmd.GoToRecord , , acNewRec create a new record in the form recordset, or the actual underlying recordsource/table(s)?  Would this be affected by the form RecordSource being a table vs. a query?

    Thanks so much for any input.


    Curtis Wayne

    Thursday, February 23, 2012 2:18 PM
  • I was browsing this thread, hoping someone had addressed the 2 questions I had posted:

    QUESTIONS:  Does DoCmd.GoToRecord , , acNewRec create a new record in the form recordset, or the actual underlying recordsource/table(s)?  Would this be affected by the form RecordSource being a table vs. a query?

    Do you have any input personally?  Do you think I should create a brand new thread?  I'm not real familiar with the proper protocol.

    Thanks for your input.


    Curtis Wayne

    Thursday, March 15, 2012 5:27 PM
  • I would definately post a new thread as many posters do not read Answered threads.

    Chris Ward

    • Marked as answer by Curtis Wayne Thursday, March 15, 2012 9:06 PM
    Thursday, March 15, 2012 8:16 PM
  • Will do

    Thanks!


    Curtis Wayne

    Thursday, March 15, 2012 9:06 PM