Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    'No Current Record' message (Access2000+)

    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?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'No Current Record' message (Access2000+)

    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.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: 'No Current Record' message (Access2000+)

    >>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!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'No Current Record' message (Access2000+)

    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

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'No Current Record' message (Access2000+)

    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>post 401925</post#> for instructions.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'No Current Record' message (Access2000+)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •