Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435

    Unexpected error 3021, "No Current Record"

    I have a form bound to a query with the following OnOpen event code:

    Code:
        Me.RecordsetClone.FindFirst "RegistryID = " & lngRecID
        Me.Bookmark = Me.RecordsetClone.Bookmark
    Here's a snippet of the query revealing the ID field being searched:


    Click image for larger version. 

Name:	000.jpg 
Views:	19 
Size:	14.2 KB 
ID:	44356

    I get error 3021, "No Current Record" when I attempt to Bookmark. Debug clearly indicates a valid ID value, so I don't know what the problem is. I also tried "[RegistryID] = " but that made no difference.
    Click image for larger version. 

Name:	001.jpg 
Views:	17 
Size:	28.4 KB 
ID:	44357

    What might be the cause of the error?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,604
    Use OnLoad event. AFAIK a form has no records during open event. Did you make sure lngRecID is not null? (I see that in your pic now, but is there a record with an ID of 100?).

    A good reference
    https://support.microsoft.com/en-us/...7-ce86553682f9
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,682
    In general I avoid using the forms Open event unless it's to cancel opening the form for some reason.
    (User access denied etc.)
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    Same error in the OnLoad event code. And yes, I'd already confirmed the record exists.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,252
    Can you show us the form please in design view? Do you have on the from a control bound to the RegistryID field?

    Cheers.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    Do you have on the from a control bound to the RegistryID field?
    No, so I added one and I still get the error. (I'm used to having to do such things with Reports, even if excluded from the report's display but otherwise used in some other context.)

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,252
    Can you show us the entire code (where does lngRecID gets its value)?
    I have posted a couple of days ago a similar code in this forum and it works OK:
    Code:
    Private Sub Form_Load()
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "[RegistryID] = " & 100'default record
    Me.Bookmark = rs.Bookmark
    Set rs = Nothing
    End Sub
    So it must be something else going on in your case. Could it be possible that RegistryID is set up as a lookup field in the table?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,682
    Maybe show us the whole forms open code in case something else is amiss?

    It seems a bit strange.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,604
    Can you actually use the bookmark property on a recordsetclone object? Seems that any examples I've ever seen or used treat the bookmark as a property of a recordset (DAO or ADO) or the form itself, not Me.RecordsetClone.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    I changed to use your approach referencing the DAO recordset rather than would otherwise be the form's RecordSource but the issue persists.
    Click image for larger version. 

Name:	003.jpg 
Views:	10 
Size:	102.9 KB 
ID:	44361

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    Nothing very exciting with the OnOpen.................
    Code:
    Private Sub Form_Open(Cancel As Integer)
    '*=*=*=*=*=*=*=*=*=*=*=*=( OPEN OPEN OPEN OPEN OPEN )=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ImagePath = "c:\" & DLookup("SetTopFldr", "tblSettings")
    ImagePath = ImagePath & "\" & DLookup("SetImageLib", "tblSettings")
    DefaultImage = ImagePath & "\DefaultPic.jpg"
    
    Me.cmdFinished.SetFocus
    
    End Sub

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    Below is "production level code" from another similar app probably written 20+ years ago. Notice it's in the OnOpen, not OnLoad.
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
    If IsNull(Me.OpenArgs) Then                  'Not being invoked subordinate to table form.
        LastName.SetFocus
        If IsNull([LastName]) Or Me.FilterOn Then Exit Sub
        LblAlpha.Visible = True
        Box9.Visible = True
        Me.NavigationButtons = True
    Else                                         'Being invoked via double-click in table form.
        Me.OrderBy = "LastName"
        'Move to the record specified in open parameter
        If Me.OpenArgs = "NewEntry" Then Exit Sub
        Me.RecordsetClone.FindFirst "[RegistryID] = " & Me.OpenArgs
        Me.Bookmark = Me.RecordsetClone.Bookmark
        LastName.SetFocus
    End If
    
        If cboBaptized = "Yes" Then
            tbBapDate.Enabled = True
        Else
            If Len(cboBaptized & "") = 0 Then
                cboBaptized = "Unknown"         'Only new records will default to "Unknown"
            End If
        End If
    
    Call SetImagePath
    
    End Sub

  13. #13
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,682
    Okay - the obvious answer then is that that record doesn't exist in the forms recordset then.

    Have you double/triple checked it really is there?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  14. #14
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,435
    Could it be possible that RegistryID is set up as a lookup field in the table?
    No: The Lookup property for RegistryID field is empty
    Click image for larger version. 

Name:	004.jpg 
Views:	10 
Size:	14.0 KB 
ID:	44362

  15. #15
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,604
    Can you post a stripped down copy of the db with enough in it to replicate the error?
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-10-2020, 11:18 AM
  2. Runime Error '3021': - No current record
    By Mohanss82 in forum Programming
    Replies: 2
    Last Post: 07-04-2016, 02:34 AM
  3. sql error . runtime 3021 - no current record
    By princess12 in forum Access
    Replies: 3
    Last Post: 04-10-2015, 09:26 AM
  4. Error 3021 no current record
    By bbrazeau in forum Programming
    Replies: 10
    Last Post: 12-13-2012, 04:22 PM
  5. "No Current Record" error...not sure why it is there
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 01-25-2011, 10:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums