Results 1 to 6 of 6
  1. #1
    srmezick is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Posts
    15

    Looping Search


    I would like to create a search that will return to the first record found when it comes to the last one. Any ideas?

  2. #2
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by srmezick View Post
    I would like to create a search that will return to the first record found when it comes to the last one. Any ideas?
    Not sure what you mean. Can you explain on what you are trying to achieve?

  3. #3
    srmezick is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Posts
    15
    Currently when users search for a record in the database (a database containing various employee information) when the search reaches the last record, it will not continue to search and return to the first record. For example if I am searching for an employee with the last name smith, and there are 7 smiths in the database, it will display the first record, then if you "re-search" it will display the second and so on. However, if the user for some reason overlooks the particular smith he/she is looking for, when he/she comes to the 7th smith, the database search bar, as well as any buttons I have created, if he/she tries to continue to search for "Smith" it will tell him/her access has completed the search and has not found any records matching the criteria. What I would LIKE to happen is when he/she gets to the 7th smith, and wishes to continue searching, the search will return to the 1st smith, then second and so on and so forth until the user does not miss the record for which they are searching.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Still not sure I'm following the issue.
    What if you used the search term to create an sql Select statement with a Where clause, and used that SQL as the recordSource of a form that you open in Datasheet.
    Then you would see all of the "found" records.

    As a matter of fact you could do a DCOUNT before actually doing the Search to make sure records existed and then do the search. If no matching records exist, then issue a message saying that.

    Just my $.02

  5. #5
    srmezick is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Posts
    15
    Not sure how I could explain it any clearer than I have explained it. Your suggestion sounds pretty complicated for my expertise in the program, not sure I could acheive it with out additional help. I might stick with my original suggestion to the users, which is that they be aware of the current record before they continue searching, or they start the search over from the beggining if they do in fact miss the record for which they are searching. Im sure a few times of trying to enter a record that already exists and not being able to duplicate an existing record will enstill a bit of awareness in them. LoL

  6. #6
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by srmezick View Post
    Not sure how I could explain it any clearer than I have explained it. Your suggestion sounds pretty complicated for my expertise in the program, not sure I could acheive it with out additional help. I might stick with my original suggestion to the users, which is that they be aware of the current record before they continue searching, or they start the search over from the beggining if they do in fact miss the record for which they are searching. Im sure a few times of trying to enter a record that already exists and not being able to duplicate an existing record will enstill a bit of awareness in them. LoL
    Are you using the filter by form function in the ribbon? If so, there is not other ways around what you are getting. I usually create my own search function. One suggestion is to create a listbox for the search result (last name). Above the list box, create a search text box. In the "On Change" event for the search test box put in the following"

    Private Sub SearchTxt_Change()
    Dim sSearch as String
    Dim sSql as String

    sSearch = Me.SearchTxt.Text 'I named the search text field as SearchTxt
    sSql = "Select LastName & ', ' & FirstName AS EmpName From YourTblName "
    sSql = sSql & "Where LastName Like '" & sSearch & "*'"

    Me.YourListBox.Rowsource = sSql 'assigns the sql to the rowsource
    Me.YourListBox.Requery
    End Sub

    What this does is that when the user start typing the last name, the result in the list box narrows.

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

Similar Threads

  1. Looping through Records in SQL
    By make me rain in forum Queries
    Replies: 13
    Last Post: 07-17-2011, 08:58 AM
  2. Looping in Access
    By ducthang88 in forum Programming
    Replies: 2
    Last Post: 12-04-2010, 07:43 PM
  3. Looping through a tbl to find a certain value
    By cwf in forum Programming
    Replies: 1
    Last Post: 05-17-2010, 04:02 PM
  4. Looping code for printing reports
    By Lockrin in forum Access
    Replies: 2
    Last Post: 02-09-2010, 05:48 AM
  5. Looping syntax
    By fadiaccess in forum Access
    Replies: 1
    Last Post: 10-23-2009, 02:57 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