Results 1 to 3 of 3
  1. #1
    nickmit11 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    9

    Question Search with Text Box for Next Record on a Form (VBA)

    I am trying to set up a search bar that jumps from one record, to the next record, and so on. The data that I am using repeats numbers, not a lot of them but enough to make it relevant. So far I have been able to build a code that when I enter my number in a textbox it jumps to the first instance that this number is found in my data and displays it on the form. I have not been able to get it to then jump to the NEXT instance of this number. I am not a great coder and I have been playing around with it, but my code that is currently able to find the first record is listed below, any help would be greatly appreciated!!

    Private Sub cmdSearch_Click()
    Dim bkmk As Variant


    Dim strField As String
    Me.RecordsetClone.MoveFirst
    'Find the first record that matches what
    'is in the search text box.
    Me.RecordsetClone.FindFirst "[Inspection]![Loc #:] Like " _
    & Chr(34) & Me.txtSearch & "*" & Chr(34)
    If Me.RecordsetClone.NoMatch Then
    MsgBox "No Dice"
    Else
    bkmk = Me.RecordsetClone.Bookmark
    Me.Recordset.Bookmark = bkmk
    End If
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Use a filter to show all the records,then there's no guesswork...

    Code:
    sub txtFilter_afterUpdate
      if isNull(txtFilter) then 
          Me.FilterOn=false
      else
           Me.Filter ="[id]=" & me.txtFilter
            Me.FilterOn=true
       End if
      end sub

  3. #3
    nickmit11 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    9
    Quote Originally Posted by ranman256 View Post
    Use a filter to show all the records,then there's no guesswork...

    Code:
    sub txtFilter_afterUpdate
      if isNull(txtFilter) then 
          Me.FilterOn=false
      else
           Me.Filter ="[id]=" & me.txtFilter
            Me.FilterOn=true
       End if
      end sub
    I have been trying to get this to work to no avail. The way my form, and this search text box search are set up is so that I can jump to any single record within the form and edit/update that info. However some of the records have repeat company identification numbers, not primary key, and so this is why I need to be able to jump from one record to the next without changing the value in the search text box

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

Similar Threads

  1. Replies: 7
    Last Post: 06-05-2015, 11:13 AM
  2. Replies: 6
    Last Post: 02-02-2015, 02:14 PM
  3. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  4. Replies: 1
    Last Post: 04-20-2012, 03:16 AM
  5. Replies: 2
    Last Post: 03-01-2012, 12:21 PM

Tags for this Thread

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