Results 1 to 13 of 13
  1. #1
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64

    Next Record safety

    Hello, I'm working with Record Numbers, it is possible to make a Message Box warning "You are on the last record?" when I'm on the Last Record, but even then click on Next Record?

    Example of the last part, but I'm missing the start of it.
    MsgBox "You are at the last record?"
    DoCmd.CancelEvent
    Else
    DoCmd.GoToRecord , , acNext 'Go to next record
    End If

    Regards,


    Jaap

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Maybe just let the "next" button error code take care of it but create your own message. Something like:

    Private Sub Next_Click()
    On Error GoTo Next_Click_Err

    DoCmd.GoToRecord , "", acNext

    Next_Click_Exit:
    Exit Sub

    Next_Click_Err:
    Msgbox "You are on the last record."
    Resume Next_Click_Exit

    End Sub

  3. #3
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Code:
    Maybe just let the "next" button error code take care of it but create your own message
    Thank you, I've tried your example, but at the last Record, and then click on Next Record, he's going further, without warning.

    Private Sub VolgendRecord_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error GoTo Next_Click_Err
    DoCmd.GoToRecord , "", acNext
    Next_Click_Exit:
    Exit Sub
    Next_Click_Err:
    MsgBox "You are on the last record."
    Resume Next_Click_Exit
    End Sub

    Sorry, Dutch language
    Click image for larger version. 

Name:	Navigation buttons.png 
Views:	26 
Size:	4.7 KB 
ID:	28942

    Is there anything to do with this data?
    Click image for larger version. 

Name:	Currrent record.png 
Views:	25 
Size:	1.3 KB 
ID:	28943

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Try this in your Sub:

    Private Sub Next_Click()
    On Error GoTo Next_Click_Err

    If Me.CurrentRecord = 1 Then
    'First record
    DoCmd.GoToRecord , "", acNext
    Else
    If Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
    'Last Record
    MsgBox "Last record"
    Else
    'not first or last
    DoCmd.GoToRecord , "", acNext
    End
    End If
    End If

    Next_Click_Exit:
    Exit Sub

    Next_Click_Err:
    MsgBox Error$
    Resume Next_Click_Exit

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Also check out this example of record navigation buttons: http://www.lebans.com/recnavbuttons.htm

  6. #6
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Code:
    Try this in your Sub:
    Thank you very much Bulzie, it's working now very well. :-)

    Here the result!
    Click image for larger version. 

Name:	Last record.png 
Views:	21 
Size:	12.4 KB 
ID:	28945

    I would like to know what the meaning of Me.RecordsetClone.RecordCount is please?

    If Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
    'Last Record
    MsgBox "Last record"

    Regards,
    Jaap

  7. #7
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Quote Originally Posted by HiTechCoach View Post
    Also check out this example of record navigation buttons: http://www.lebans.com/recnavbuttons.htm
    Thank you, I'm working with MS Office 2016
    Click image for larger version. 

Name:	Opening mdb file.png 
Views:	22 
Size:	19.4 KB 
ID:	28946

    Jaap

  8. #8
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    If Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
    The CurrentRecord is the value of the record in the navigation part at the bottom of the form so is 1 if you are on the first record and 50 if you have 50 records and are on the last record, etc.
    Me.RecordsetClone.RecordCount: RecordsetClone is your forms records and when you add RecordCount, that is the total number of those records so would be the number 50 if you have 50 records displaying on the form.

    So when those 2 values are equal, you are on the last record.

  9. #9
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Ok Bulzie, thanks for the clear explanation.

    Regards,
    Jaap

  10. #10
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by Jaap View Post
    Thank you, I'm working with MS Office 2016
    Click image for larger version. 

Name:	Opening mdb file.png 
Views:	22 
Size:	19.4 KB 
ID:	28946

    Jaap
    Staring with Access 2013, it willno longer open a Access 97 database. It will open an Access 2000 (2K) or later version.

    You should be able to open the Access 2000 (A2K) version. It is the top link.

  11. #11
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Code:
    You should be able to open the Access 2000 (A2K)  version. It is the top link.
    Thank you HiTechCoach, I've tried several times, but I can't fix it
    I can not find a properly tutorial in YouTube as well.
    With Access help I found this, but I can't open the old A97NavButtonsver6.mdb file
    Click image for larger version. 

Name:	Save as access.png 
Views:	19 
Size:	23.8 KB 
ID:	28954

    Regards,
    Jaap
    Last edited by Jaap; 06-02-2017 at 12:28 AM. Reason: writing error

  12. #12
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by Jaap View Post
    Code:
    You should be able to open the Access 2000 (A2K)  version. It is the top link.
    Thank you HiTechCoach, I've tried several times, but I can't fix it
    I can not find a properly tutorial in YouTube as well.
    With Access help I found this, but I can't open the old A97NavButtonsver6.mdb file
    Click image for larger version. 

Name:	Save as access.png 
Views:	19 
Size:	23.8 KB 
ID:	28954

    Regards,
    Jaap
    You can open the A97NavButtonsver6.mdb with Acess 2013 or later.

    Did you try the A2kNavButtonsver7.mdb?
    That is the one that works with Aces 2013 and later.

    A2KRecordNavigationButtons is an MDB containing code to replace the standard Navigation Buttons. The custom buttons exactly emulate the standard navigation bar including the autorepeat property. A2K or higher! Modified by MVP Graham Mandeno to work properly with multiple SubForm configurations.


  13. #13
    Jaap's Avatar
    Jaap is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Location
    North Holland
    Posts
    64
    Thank you HiTechCoach, now I can open the "A2KNavButtonsver7.mdb" file.

    Regards,
    Jaap.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-12-2016, 02:49 PM
  2. Help with Safety DB set up
    By dluga20 in forum Access
    Replies: 13
    Last Post: 06-02-2015, 06:49 AM
  3. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  4. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  5. turning off safety prompts
    By rbtrout in forum Access
    Replies: 4
    Last Post: 04-26-2011, 04:26 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