Results 1 to 7 of 7
  1. #1
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103

    Facing problem Button Next and Previous Nor working after getting specific record

    Hi
    I am Facing problem Button Next and Previous Nor working after getting specific record "ID"
    I have One Form/Report in which I have linked the ID to form
    Now when I open second form by clicking on first form's ID its work perfect.
    When enter ID in second Form to search its work perfect.
    But when I work on Next and Previous button on second form its not work and get error, while If I directly open second form its navigation button worked perfect? Let me know what/where is the problem?
    There is db sample attached where it can be checked by opening report and by clicking on report ID After opening the Form by clicking on ID the navigation buttons not work.


    GotoNext Nor working if open Form through Report.zip

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You are opening the form filtered to the selected record. As a result there is only one record and you can't move to a previous or next ID.
    If that's your intention, you need to change the code so it opens the form unfiltered then moves to the selected record
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by isladogs View Post
    You are opening the form filtered to the selected record. As a result there is only one record and you can't move to a previous or next ID.
    If that's your intention, you need to change the code so it opens the form unfiltered then moves to the selected record


  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
    Like this:

    In the Primary Form:
    Code:
    Private Sub Go2SecondaryForm_Click()
    
     If Nz(Me.RecordID,"") <> "" Then
      DoCmd.OpenForm "Secondary Form", , , , , , Me.RecordID
     Else
      MsgBox "A RecordID Must Be Entered First!"
     End If
    
    End Sub


    In the Secondary Form:

    Code:
    Private Sub Form_Load()
    
    Dim rst As Recordset
    
    If Nz(Me.OpenArgs,"") <> "" Then
    
     Set rst = Me.RecordsetClone
     
     rst.FindFirst "[RecordID] = " & Me.OpenArgs 
     
       If Not rst.NoMatch Then
        Me.Bookmark = rst.Bookmark
       Else
        Msgbox "Matching Record Not Found!"
       End If
    
    rst.Close
    Set rst = Nothing
    
    End If
    
    End Sub


    The above code assumes that RecordID is Numeric. If it is actually defined Text, replace the line

    rst.FindFirst "[RecordID] = " & Me.OpenArgs

    with

    rst.FindFirst "[RecordID] = '" & Me.OpenArgs & "'"

    You'll also need to replace Go2SecondaryForm with the actual name of your SecondaryForm.

    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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Ijaz
    Does linq's answer clarify the approach for you?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by Missinglinq View Post
    Like this:

    In the Primary Form:
    Code:
    Private Sub Go2SecondaryForm_Click()
    
     If Nz(Me.RecordID,"") <> "" Then
      DoCmd.OpenForm "Secondary Form", , , , , , Me.RecordID
     Else
      MsgBox "A RecordID Must Be Entered First!"
     End If
    
    End Sub


    In the Secondary Form:

    Code:
    Private Sub Form_Load()
    
    Dim rst As Recordset
    
    If Nz(Me.OpenArgs,"") <> "" Then
    
     Set rst = Me.RecordsetClone
     
     rst.FindFirst "[RecordID] = " & Me.OpenArgs 
     
       If Not rst.NoMatch Then
        Me.Bookmark = rst.Bookmark
       Else
        Msgbox "Matching Record Not Found!"
       End If
    
    rst.Close
    Set rst = Nothing
    
    End If
    
    End Sub


    The above code assumes that RecordID is Numeric. If it is actually defined Text, replace the line

    rst.FindFirst "[RecordID] = " & Me.OpenArgs

    with

    rst.FindFirst "[RecordID] = '" & Me.OpenArgs & "'"

    You'll also need to replace Go2SecondaryForm with the actual name of your SecondaryForm.

    Linq ;0)>

    Oh Grate You have done it Wonderful!!!
    Thanks a lot Its working Perfect 100% as I required.

  7. #7
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by isladogs View Post
    Ijaz
    Does linq's answer clarify the approach for you?
    Yes his method worked for me grate. I was much worried about this problem because I have to open the form manually and also from report and full form and now the problem solved.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-01-2015, 10:56 AM
  2. Replies: 4
    Last Post: 03-28-2014, 12:38 PM
  3. How do i make a button that will go to a specific record?
    By TOMMY.MYERS668 in forum Programming
    Replies: 2
    Last Post: 02-08-2013, 07:54 AM
  4. Replies: 22
    Last Post: 06-12-2012, 10:02 PM
  5. Replies: 1
    Last Post: 04-09-2012, 02:14 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