Results 1 to 6 of 6
  1. #1
    ramindya is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    20

    Next unique record ( Record Navigation )

    I have a table named TableA which consists of following : ( ID is primary key )

    ID SSN Lastname PHONENUMBER
    1 123456789 ASHOK 5097863736


    2 123456789 ASHOK 6572527257
    3 897262562 KUMAR 9897867298
    4 897262562 KUMAR 6572357373

    The subform shows lists data by individual person one person at a time which means

    ID SSN Lastname PHONENUMBER
    1 123456789 ASHOK 5097863736
    2 123456789 ASHOK 6572527257

    To navigate from one record to next in the subform I use the record navigation which defualt comes with ms access.

    Problem: The mainform also has navigation but it goes through all the records sequentially.
    But I want to go next record ( a custom navigation or something like that ) that is..

    FROM

    1 123456789 ASHOK 5097863736

    TO

    3 897262562 KUMAR 9897867298

    Can somebody let me know how to that ?

    Thanks !!

  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
    Are you saying you don't want the subform to even have the second record for each person in its recordset?
    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
    ramindya is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    20
    I just want to add a navigation button in the main form so I can go.

    FROM

    ID SSN Lastname PHONENUMBER
    1 123456789 ASHOK 5097863736

    TO

    ID SSN Lastname PHONENUMBER
    3 897262562 KUMAR 9897867298

    Thanks for the spontaneous reply!


  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
    Might be able to do something with the RecordsetClone. Review this http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    Maybe something like:
    Code:
    Sub GoToNextSSN_Click()
    Me.RecordsetClone.FindFirst "ID>" & Me.ID & " AND SSN <>'" & Me.SSN & "'"
    If Me.RecordsetClone.NoMatch Then
       MsgBox "Record not found"
    Else
       Me.Bookmark = Me.RecordsetClone.Bookmark
    End If
    End Sub
    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
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931

    Unique Record

    Let me explain what I understand your problem is:

    You want to navigate to unique records each time you click a next button. That is move to the next unique SSN Number as per the example provided. This is what I have done:

    I have a table with the Following Fields:

    ID (PK) (Autonumber)
    SSN (Number)
    LastName (Text)
    PhoneNumber (Number)

    Example

    ID SSn LastName PhoneNumber
    1 123456789 Ashok 5097863736
    2 123456789 Ashok 6572527257
    3 897262562 Kumar 6572357373
    4 897262562 Kumar 9897867298
    5 897262569 Majumdar 9007897997

    This is an extract from my table. When your form opens you will looking at Entry with ID:1 SSn:12345678 LastName:Ashok PhoneNumber:5097863 and you want to jump to Entry ID:3 SSn:89726562 LastName:Kumar PhoneNumber:6572357373

    The Code:

    Code:
    Dim rst As DAO.Recordset
    Dim strSQL As String
    Dim myRecordSource As String
    Dim intMyID As String
    
    strSQL = "Select * From Table1 Where ID>" & Me.ID
    Set rst = CurrentDb.OpenRecordset(strSQL)
    Do While Not rst.EOF
    If rst!SSn <> Me.SSn Then
        intMyID = rst!ID
        Exit Do
    End If
    rst.MoveNext
    Loop
    
    rst.Close
    Set rst = Nothing
    
    myRecordSource = "Select * From Table1 Where ID=" & intMyID
    Me.RecordSource = myRecordSource
    Me.Requery
    End Sub
    What does the code do:

    1) Opens a recordset selects all records with ID number more than the first record displayed in the form.
    2) Loops through the records
    3) Loop stops when encounters an entry with a SSN number <> equal to the SSN number displayed in the record.
    4) Assigns the ID value to the Variable intMyID
    5) Use the intMyID to filter the next record.
    6) Make myRecordSource the RecordSource of the form.


    Note: You will need to change the recordsource of the form to make it show all the records.

  6. #6
    scoobz1234 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    41
    i have a similar issue, where i think this may work, i have a database with over 1000 names in it, each name has a unique identifier we call a Division. there are 7 different divisions. in a form i have a combo box with the 7 divisions in it, is there a way to apply a filter once i select a division from the combo box, so when i click next record it only cycles through the records that have that division number?

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

Similar Threads

  1. Navigation Bar Record Count not updating
    By ylatodd in forum Forms
    Replies: 27
    Last Post: 02-13-2012, 10:45 AM
  2. Record/form navigation problem
    By kris335 in forum Access
    Replies: 1
    Last Post: 09-19-2011, 09:41 AM
  3. Creating unique record from record and field data
    By arthurpenske in forum Access
    Replies: 3
    Last Post: 08-24-2011, 06:11 PM
  4. Unique table per record?
    By Poepol in forum Access
    Replies: 8
    Last Post: 06-11-2011, 10:31 AM
  5. Record Navigation bar
    By sabre1 in forum Forms
    Replies: 5
    Last Post: 05-18-2011, 03:44 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