• ‘No Current Record’ message (Access2000+)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » ‘No Current Record’ message (Access2000+)

    Author
    Topic
    #419835

    I have code that I’ve never had a problem with in Access97 or Access2000. But in Access2003 generates an error every time in a particular circumstance. I have a SAVE button on a form, and the code for the button and the forms BeforeUpdate looks something like t his:
    Private Sub cmdSave_Click()
    If me.dirty then runcommand acCmdSaveRecord
    If me.dirty then Exit Sub
    ‘ other code
    End Sub

    Private sub Form_BeforeUpate (Cancel as integer)
    if isnull(txtCustomerName) then
    MsgBox “Fix customer name”
    Cancel=True
    Exit Sub
    End if
    Exit Sub

    In my real code, I have error handling in both events. If this is a new record, and if there is a null entry in txtCustomerName, this generates an error# 3021 “No Current Record” error in the error handler in my cmdSave_Click code. If it is an existing record, there is no such error raised.

    Curiously, this error isn’t raised if the BeforeUpdate event code is triggered from such action as trying to move to a subform so that Access tries to save the record.

    I’ve gotten around this by putting this line of code in error handler:
    If err.number =3021 then Resume ExitHere

    But I use this code technique alot, in every button that may or should force the record to be saved. Going into all of them on every form will be a pain.

    Any ideas why this is happening?

    Viewing 0 reply threads
    Author
    Replies
    • #949065

      In Access 2002, I get error 2501 – the RunCommand action has been canceled. I’m afraid you’ll have to chose between adding a line such as you suggest yourself, or create a function that checks whether the record can be saved, and call this before you try to save it.

      • #949067

        >>In Access 2002, I get error 2501 – the RunCommand action has been canceled. I’m afraid you’ll have to chose between adding a line such as you suggest yourself, or create a function that checks whether the record can be saved, and call this before you try to save it.<<

        And Microsoft still doesn't understand why we don't just automatically upgrade each time they come out with a new version!

        • #996870

          Mark/Hans

          I’m interested in this thread because I have just come across a similar error/problem.

          We’ve just upgraded an Access 97 system to Access 2002. All the object forms are unbound, and there is error-trapping throughout, specifically to pick the up the 2501 error mentioned in this thread.

          However, in 2002 we have added a new form, which is very similar to the other unbound forms. The problem is that cancelling the Unload event generates a 3021 error “No current record” – but this is an unbound form. I don’t get this at all.

          Do you experts have any thoughts on this ? Here’s the code which runs when the Close button is clicked : Message 6 asks whether the users wants to Save, close or Continue

          If mobjClientSponsorRecipient.ffcnCheckType = False Then

          Call msubDisplayMessage(gstrcAppName, strResponse, 6, vbNullString, vbNullString)

          Select Case strResponse

          Case vbYes

          If mobjClientSponsorRecipient.ffcnValidateForm(Me) Then
          If mobjClientSponsorRecipient.ffcnSave Then
          Cancel = False
          Else
          Cancel = True
          End If
          Else
          Cancel = True
          End If
          Case vbNo
          Cancel = False
          Case vbCancel
          Cancel = True

          End Select

          End If

          Exit_Form_Unload:
          On Error Resume Next
          Exit Sub

          Err_Form_Unload:
          Call msubStandardErrorTrap(gcERROR, gcDETAIL, strcFormOrModuleName, strProcOrFunctionName, Err.Number, Err.description, vbNullString)
          Resume Exit_Form_Unload

          When vbCancel is returned the 3021 error is generated. Very odd.

          Your help is appreciated as always

          Nick

          • #996924

            I cannot reproduce this problem, and I can’t find a mention of it elsewhere, so I fear there’s little I can do without seeing the database. If you wish, you can a stripped down copy of your database. See post 401925 for instructions.

            • #996933

              Hans

              I think I have found an answer of sorts. It appears (from other mentions on the net) to be a problem introduced in SP3. I have managed to get round by checking for errors 3021 and 3146 in the code, and ignoring them. This seems to work for now anyway.

              Thanks

              Nick

    Viewing 0 reply threads
    Reply To: ‘No Current Record’ message (Access2000+)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: