Results 1 to 3 of 3
  1. #1
    Wagon is offline Novice
    Windows 7 64bit Access 2002
    Join Date
    Dec 2015
    Posts
    11

    Searching through records on a form

    Good Afternoon,

    I currently have a form based on a table in my database and wish to be able to search though it to find a specific record

    The code I currently have is this:

    Private Sub Command36_Click()
    Dim searchtext
    Dim searchcode


    searchtext = txtsearch.Value
    searchcode = [Text1].Value


    If searchtext = searchcode Then
    MsgBox "Search Complete"
    Else
    DoCmd.GoToRecord , , acNext


    End If
    Exit Sub
    End Sub

    This works fine with the exception of that I have to keep clicking the button to find the record i want. I have tried a loop but i have never used them before and must have done it wrong as it didn't work at all.

    If anyone could make any suggestions it would be much appreciated



    Thank you

    Regards

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    instead of searching 1 by 1, just filter them all....



    Private Sub Command36_click()
    me.filter = "[code]='" & txtSearchBox & "'"
    me.filterOn = true
    end sub


    turn the filter off (top toolbar) to see all recs again

  3. #3
    Wagon is offline Novice
    Windows 7 64bit Access 2002
    Join Date
    Dec 2015
    Posts
    11
    That works Perfectly

    Thank you so much

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

Similar Threads

  1. Replies: 8
    Last Post: 09-15-2015, 11:34 AM
  2. Replies: 6
    Last Post: 07-27-2015, 10:23 AM
  3. Replies: 1
    Last Post: 02-06-2015, 08:07 AM
  4. Replies: 12
    Last Post: 04-07-2012, 12:09 PM
  5. Replies: 10
    Last Post: 01-10-2011, 07:52 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