Results 1 to 11 of 11
  1. #1
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124

    How to make a notifications when going to the last record or back to the first record


    Dear all,

    How to make a notifications when going to the last record or back to the first record

    Previous Button is ok

    Code:
    Private Sub gotoPrevious_Click() 
    On Error GoTo Err_gotoPrevious_Click         
    With Me.lstItems       
    .SetFocus       
    If .ListIndex < .ListCount Then          
    .ListIndex = .ListIndex - 1          
    MsgBox "First Contact", , "First Contact"       
    End If    
    End With 
    Exit_gotoPrevious_Click:    
    Exit Sub 
    Err_gotoPrevious_Click:    
    'MsgBox Err.Description    
    'MsgBox "End the Record"    
    Resume Exit_gotoPrevious_Click 
    End Sub
    Next button not ok
    Code:
    Private Sub gotoNext_Click()  
    On Error GoTo Err_gotoNext_Click    
    With Me.lstItems       
    .SetFocus     
    If .ListIndex < .ListCount Then         
    .ListIndex = .ListIndex + 1         
    'MsgBox "End the Contact", , "End the Contact"          
    End If    
    End With Exit_gotoNext_Click:    
    Exit Sub Err_gotoNext_Click:     
    MsgBox Err.Description    
    Resume Exit_gotoNext_Click 
    End Sub
    Last edited by June7; 06-13-2012 at 07:27 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why doesn't it work - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124
    It's back to first record ...

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, it's back to first record, what's wrong with that - error message, wrong results, nothing?

    Have you step debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124
    Many Thanks,

    Don't have any error but i want when click next button to last record will be message: This is Last Record

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What are these buttons for? I originally thought they were for navigating between records of a form but on second look appears you are moving between items of a list box? Why a button for that?

    Provide a complete description of what you want to accomplish, what you have tried, and the issues you have encountered.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124
    I have a next record as image below:



    I'm using code below, it's cant stop at last record

    Code:
    Private Sub gotoNext_Click()
     On Error GoTo Err_gotoNext_Click
    
       With Me.lstItems
          .SetFocus
          If .ListIndex < .ListCount Then
             .ListIndex = .ListIndex + 1
          End If
        
       End With
    
    Exit_gotoNext_Click:
       Exit Sub
    
    Err_gotoNext_Click:
       'MsgBox Err.Description
       Resume Exit_gotoNext_Click
    End Sub

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Still not understanding the behavior. Is lstItems a listbox? How does referencing that listbox control record navigation? Want to provde project for analysis? Follow instructions at bottom of my post.
    Last edited by June7; 06-14-2012 at 07:46 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124
    It's lstItems a listbox ....

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That doen't answer my question about how listbox controls record navigation. I have never encountered this technique before. If you won't explain it or provide the project, I can't help.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    uronmapu is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    124
    Done

    Share code below for all

    Code:
    Private Sub gotoNext_Click()
    On Error GoTo Err_gotoNext_Click
        
       With Me.lstItems
          .SetFocus
          If [lstItems].
    [ListIndex] + 1 < [lstItems].
    [ListCount] - 1 Then
             .ListIndex = .ListIndex + 1
             ElseIf [lstItems].
    [ListIndex] + 1 = [lstItems].
    [ListCount] - 1 Then
             MsgBox "End the Record"
             
          End If
       End With
    Exit_gotoNext_Click:
       Exit Sub
    Err_gotoNext_Click:
       'MsgBox Err.Description
       'MsgBox "End the Record"
       Resume Exit_gotoNext_Click
    End Sub

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

Similar Threads

  1. is there is a way to make a record locked
    By Nokia N93 in forum Access
    Replies: 5
    Last Post: 05-11-2011, 02:47 PM
  2. Replies: 1
    Last Post: 11-02-2010, 09:06 AM
  3. Help on macro to scroll one record back?
    By getholdofjoru in forum Forms
    Replies: 2
    Last Post: 06-19-2010, 03:01 PM
  4. Refresh All goes back to First Record
    By diane802 in forum Forms
    Replies: 4
    Last Post: 12-30-2009, 04:24 PM
  5. Replies: 3
    Last Post: 06-27-2009, 03:53 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