Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    "No current record" message

    There are many forms in my program and many types of events are written. When I close the form, this error is generated. Even after trying hard, I am not able to find out which coding causing this error. Is there any way I can find out which coding error is generating this error in which event?
    Thank you.
    Attached Thumbnails Attached Thumbnails noUntitled.png  

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Turn on "Break on All Errors"
    See: https://www.fmsinc.com/tpapers/vbaco...sume%20Next%22.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I fixed that on one of your forms by removing a mountain of unnecessary / unused code.
    You should get in the habit of commenting out anything you aren't actually using, and then deleting it once you have tested things and know everything still works.

    It normally has something to do with you trying to go to a new record when you are already on one.
    You can check for that by using before running certain code.

    Code:
    If Me.NewRecord...
    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
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Bob Fitz View Post
    Turn on "Break on All Errors"
    See: https://www.fmsinc.com/tpapers/vbaco...sume%20Next%22.
    Hello Bob, I have been trying many times by studying the link given by you but till now I am not able to catch the error and its solution.
    Thank you

  5. #5
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    I fixed that on one of your forms by removing a mountain of unnecessary / unused code.
    Thanks for replying minty.

    I have removed all the unnecessary codes written in the form.
    I have done some coding in main form and sub form to set row limit 30 in sub form which is as follows


    Code:
    In the main form
    
    Private Sub Form_Current()
    
    With Me.GREY_SHADE.Form
     If .Recordset.RecordCount < 30 Then
    .AllowAdditions = True
    Else
    .AllowAdditions = False
    End If
    End With
    
    End Sub
    
    
    
    In the sub form
    
    Private Sub Form_AfterInsert()
    
    If Me.Recordset.RecordCount = 30 Then
    MsgBox "You Don't enter more than 30 Shades & Meters"
    Me.AllowAdditions = False
    End If
    
    End Sub
    
    Private Sub Form_AfterDelConfirm(Status As Integer)
    If Me.Recordset.RecordCount < 30 Then Me.AllowAdditions = True
    End Sub


    Now when the offer entry form is opened and the offer number 128 is navigated to from the record navigation button at the bottom right, after then click on the "save and shade" button, after that the save button is clicked and after that on the right side top close button is click. then I get message box of "no current record" is being shown. My eyes have become red since yesterday while trying to find the reason and solution for this error but till now no solution has been found.
    Thank you.
    Attached Files Attached Files

  6. #6
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I suspect it has something to do with the form resizing(which renders the form almost unusable on my monitor by the way), and hiding the sub form (Why do you hide the sub form, it makes no sense to me?), but I can't easily see why.

    You have an exit button that doesn't give you problem. Hide the close X , and avoid the problem.

    Oh and add Option Explicit to the top of every code module, you have undeclared Labels etc. in your code.
    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 ↓↓

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    I suspect it has something to do with the form resizing(which renders the form almost unusable on my monitor by the way), and hiding the sub form (Why do you hide the sub form, it makes no sense to me?), but I can't easily see why.

    You have an exit button that doesn't give you problem. Hide the close X , and avoid the problem.

    Oh and add Option Explicit to the top of every code module, you have undeclared Labels etc. in your code.
    I have hidden the sub form because if the user clicks on the sub form without entering the required entries of the main form then the data of the main form gets auto saved. To prevent auto saving, I have hidden the sub form.

  8. #8
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Just disable the subform control then it won't do anything, otherwise you can't see if an entry has any related data.
    If it already has data in it then the main form must have had enough data recorded to allow you into it, so hiding it is just daft, and causing you a load of extra work.

    And I think another version of your problem is caused by the beforeupdate form event, where instead of using the default value you try and set it again, which dirties the form.

    Get rid of this bit of code:
    If DCount("1", "GREY_OFFER", "OfferNumber = " & Me.txt0) > 0 Then
    Me.txt0 = Nz(DMax("OfferNumber", "GREY_OFFER"), 0) + 1


    End If

    And just set the default value in the control properties to = Nz(DMax("OfferNumber", "GREY_OFFER"), 0) + 1

    And please please please, for all our sakes, give your controls meaningful names - txt0 means absolutely nothing to me, txtOfferNumber tells me and you exactly what control you are updating or checking.
    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
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    Just disable the subform control

    Get rid of this bit of code:
    If DCount("1", "GREY_OFFER", "OfferNumber = " & Me.txt0) > 0 Then
    Me.txt0 = Nz(DMax("OfferNumber", "GREY_OFFER"), 0) + 1


    End If
    Thank you very much for replying and understanding me in detail.
    I have inserted this code in the Before Update event so that this program can be run by multiple users, for example if data of up to 4 records is saved in the main table. Now if two users create an offer at the same time, then both of them will have five numbers available in the New Offer Number text box.
    But when the first user clicks on the Save and Shades button, five numbers will actually be available to him and automatically 6 numbers will be available to the second user.

  10. #10
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Well, I wouldn't populate it at all until they save the record then, that way you are pretty much guaranteed it will be unique, as you won't do the look up until the last moment.
    Or just use the autonumber, and don't worry about gaps.
    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 ↓↓

  11. #11
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    Well, I wouldn't populate it at all until they save the record then, that way you are pretty much guaranteed it will be unique, as you won't do the look up until the last moment.
    Or just use the autonumber, and don't worry about gaps.
    No no offer number interval will not good that is why I have not given it auto number field and second method according to you first saving only the offer number and then creating all the details seems quite strange. so...

  12. #12
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    This is a sample program, which is built on the lines of the same program, surprisingly it does not have that error.
    Attached Files Attached Files

  13. #13
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Hello to all of you. After a lot of hard work, I have found that if the sub form is converted from Continuous Form to Datasheet, then the "no current record" error that appears in the file I attached in comment #5 is no longer there in this attached file Is visible. Can any expert explain why this is happening and what is the solution?
    Thank you.
    Attached Files Attached Files

  14. #14
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Getting Keydown errors on numerous Controls when trying to enter data in the Main Form ?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  15. #15
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by mike60smart View Post
    Getting Keydown errors on numerous Controls when trying to enter data in the Main Form ?
    welcome mike,
    See, I have uploaded two types of files, one's name is cont type and the other name is dataset type file.
    In this, I have set the row limit to three in the sub form. When the user navigates to the previous record and clicks on the save and fill shades button, then clicks on the save button and then closes the form, then there is no error received because the subform is set on Data Sheet type.

    But if the same process is followed in cont type file then it shows the error of "no current record". Because in this I have set the sub form in Continuous Forms.
    Why is this error coming and how can it be removed?
    Thank you.

    I have done some coding in main form and sub form to set row limit 3 in sub form which is as follows


    Code:
    In the main form
    
    Private Sub Form_Current()
    
    With Me.GREY_SHADE.Form
     If .Recordset.RecordCount < 3 Then
    .AllowAdditions = True
    Else
    .AllowAdditions = False
    End If
    End With
    
    End Sub
    
    
    
    In the sub form
    
    Private Sub Form_AfterInsert()
    
    If Me.Recordset.RecordCount = 3 Then
    MsgBox "You Don't enter more than 3 Shades & Meters"
    Me.AllowAdditions = False
    End If
    
    End Sub
    
    Private Sub Form_AfterDelConfirm(Status As Integer)
    If Me.Recordset.RecordCount < 3 Then Me.AllowAdditions = True
    End Sub
    Attached Files Attached Files

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

Similar Threads

  1. MS Access Form message "No current record." box appears?
    By ramirezx@ddmfg.com in forum Access
    Replies: 1
    Last Post: 05-06-2021, 10:31 AM
  2. Unexpected error 3021, "No Current Record"
    By GraeagleBill in forum Programming
    Replies: 22
    Last Post: 02-23-2021, 08:27 PM
  3. Replies: 10
    Last Post: 09-03-2015, 01:31 PM
  4. Suppress "Error" message following "Cancel = True"
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 03-23-2014, 05:40 PM
  5. Replies: 2
    Last Post: 11-12-2013, 07:06 PM

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