Results 1 to 11 of 11
  1. #1
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46

    Trapping a GoToRecord event.

    I have a form with a GOTO control arrow on it. Actually two arrows: Previous and Next.
    On the Next arrow there is an Event procedure, no macro. The event procedure is
    straightforward. It is DoCmd.GotoRecord,,acNext. This is all and good.

    I noticed this morning that the arrow was on a split form and am scrolling through the
    datasheet when I got to the end of the list (the lsit was 40 records). The next record at the
    end of the list is blank. I got an error: "Improper use of null!" The error comes from the field
    requirements for those data elements on the form and they exist in the table. No nulls allowed.

    To make a long story short, I would like to trap the end of the list and have a more defined
    error for the user. Something like: "End of List" that I can program. The way I handled the end
    was the short screen that appears with the error message allows you to Debug or End. I simply


    pressed End and all was fine and good.

    My issue is to trap the end of the list and issue a simple message. Is this straightforward to do?

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Try setting the form property "Allow Additions" to No.

  3. #3
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46
    Quote Originally Posted by aytee111 View Post
    Try setting the form property "Allow Additions" to No.
    Aytee:

    Thanks for taking a look at my thread. Your suggestion works like a charm for getting
    rid of a confusing notice. The notice that appears says: "Cannot move beyond record!"
    This will suffice.

    I would still like to know if there is a programmatic way of trapping the message that appears
    and modifying the message to be a little softer for the user?

    Either way, I have made the modification you have suggested. Thanks Again! - Jim

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's some code that i routinely use. It 'wraps' back to the first record when reaching the last record, and vice versa; when using the 'previous' button and reaching the first record, it then goes 'back' to the last record.
    Code:
    Private Sub Go2Next_Click()
    
      If Me.CurrentRecord = Me.RecordsetClone.RecordCount Or Me.NewRecord = True Then
     
        DoCmd.GoToRecord , , acFirst
    
      Else
    
        DoCmd.GoToRecord , , acNext
    
      End If
    
    End Sub


    Code:
    Private Sub Go2Prev_Click()
    
      If Me.CurrentRecord = 1 Or Me.NewRecord = True Then
    
        DoCmd.GoToRecord , , acLast
    
      Else
      
        DoCmd.GoToRecord , , acPrevious
    
      End If
    
    End Sub


    You could replace the lines

    DoCmd.GoToRecord , , acFirst

    and

    DoCmd.GoToRecord , , acLast

    with messages boxes, if you prefer, instead of 'wrapping' the recordset.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46

    Thumbs up

    Quote Originally Posted by Missinglinq View Post
    Here's some code that i routinely use. It 'wraps' back to the first record when reaching the last record, and vice versa; when using the 'previous' button and reaching the first record, it then goes 'back' to the last record.
    Code:
    Private Sub Go2Next_Click()
    
      If Me.CurrentRecord = Me.RecordsetClone.RecordCount Or Me.NewRecord = True Then
     
        DoCmd.GoToRecord , , acFirst
    
      Else
    
        DoCmd.GoToRecord , , acNext
    
      End If
    
    End Sub


    Code:
    Private Sub Go2Prev_Click()
    
      If Me.CurrentRecord = 1 Or Me.NewRecord = True Then
    
        DoCmd.GoToRecord , , acLast
    
      Else
      
        DoCmd.GoToRecord , , acPrevious
    
      End If
    
    End Sub


    You could replace the lines

    DoCmd.GoToRecord , , acFirst

    and

    DoCmd.GoToRecord , , acLast

    with messages boxes, if you prefer, instead of 'wrapping' the recordset.

    Linq ;0)>


    I have implemented your code and everything works well. I tried it both ways and allowed the users
    to determine their preference. We ended up going with the suggested coding and did not need to use
    Message commands. Eveybody like the automatic rotation of the green bar through the datasheet.

    Many thanks for your help!

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46

    Cool Response from your recommendation!

    Quote Originally Posted by Missinglinq View Post
    Glad we could help!

    Linq ;0)>
    I want to thank you for assisting me in resolving my users concerns. Rest
    assured you are getting credit. But I opened pandora's box.

    In line with this thread, now the user wants to know if the bar that moves
    through the records can be made darker or a different color. Your code work
    very well. I have searched the literature and the books I have on Access and
    it seems no one has ever addressed this issue.

    Is the bar on a split form datasheet programmable? So far I cannot find an opinion
    one way or another. Your thoughts would be appreciated, again!

    Jim

    P.S. If you ever get to Chicago, I owe you a beer!

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I'm not sure that I understand which "bar" it is that you are referring to. Could you provide a print screen or something?

  9. #9
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46
    Quote Originally Posted by aytee111 View Post
    I'm not sure that I understand which "bar" it is that you are referring to. Could you provide a print screen or something?
    There is no way to insert an image here. Please contact me at casinc815@hotmail.com. I can forward
    a screen shot that way. The size exceeds requirements on this site. Thanks!

    Jim

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The 'bar' the OP is referring to is the 'Splitter Bar' that is native in the new, to v2007, Split Form, and the answer is No; you're pretty much stuck to either having it present or not. The color for these kind of things is defined by Windows' properties as opposed to properties of a specific app.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46
    Quote Originally Posted by Missinglinq View Post
    The 'bar' the OP is referring to is the 'Splitter Bar' that is native in the new, to v2007, Split Form, and the answer is No; you're pretty much stuck to either having it present or not. The color for these kind of things is defined by Windows' properties as opposed to properties of a specific app.

    Linq ;0)>
    Understood! Thanks for your time! I appreciate it! Jim

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

Similar Threads

  1. Replies: 4
    Last Post: 04-02-2014, 09:03 AM
  2. Trapping for EOF in Control Source
    By drblanston in forum Programming
    Replies: 5
    Last Post: 12-07-2012, 09:38 PM
  3. Append query error trapping
    By tpcervelo in forum Programming
    Replies: 4
    Last Post: 12-22-2011, 10:57 AM
  4. Proper Error Trapping
    By SemiAuto40 in forum Programming
    Replies: 6
    Last Post: 08-11-2011, 10:22 AM
  5. Form and Subform error trapping
    By usmcgrunt in forum Forms
    Replies: 8
    Last Post: 09-12-2010, 11:54 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