Results 1 to 7 of 7
  1. #1
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305

    Need help changing a "filter" button to a "go-to" button

    I have a form that looks at a bunch of customer complaints one at a time. I've got a button that allows the user to input a 'ComplaintNumber' so that they can go right to a certain complaint if needed. The issue is that it filters down to just that complaint. It'd be more useful if it only went to that complaint without filtering away the rest. I looked online for a solution but the only guides I could find were ones that filter. If anyone has any guidance or guides, that'd be awesome. Below is the code for the button that I'm currently using.

    Code:
    Private Sub btnSearchComplaintNumber_Click()    
        Dim S As String
        
        S = InputBox("Enter the Complaint Number", "Complaint Number Search")
        If S = "" Then Exit Sub
        
        Me.Filter = "ComplaintNumber = " & S
        Me.FilterOn = True
        
    End Sub


  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Posted in error
    Last edited by Welshgasman; 11-04-2021 at 02:21 AM. Reason: Posted in error
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Use a bookmark on the current forms recordset.

    An example you can adapt is here https://docs.microsoft.com/en-us/off....form.bookmark
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Probably could move to the desired record with just 2 lines:

    Me.recordsetclone.findfirst "ComplaintNumber = " & S
    Me.bookmark = Me.recordsetclone.bookmark

    I'm surprised that the posted filter code works because S is a string and in the criteria, it's not delimited at all. Would have expected you'd need
    "ComplaintNumber = '" & S & "'"


    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Quote Originally Posted by Micron View Post
    Probably could move to the desired record with just 2 lines:

    Me.recordsetclone.findfirst "ComplaintNumber = " & S
    Me.bookmark = Me.recordsetclone.bookmark
    That worked!! Thank you!!

    Quote Originally Posted by Micron View Post
    I'm surprised that the posted filter code works because S is a string and in the criteria, it's not delimited at all. Would have expected you'd need
    "ComplaintNumber = '" & S & "'"

    I tried that originally but it didn't work because the field is a number field.

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423

    I tried that originally but it didn't work because the field is a number field.
    Then you should not declare S as a string. Instead, use Integer, or probably better, Long.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    I'm not a big fan of input boxes and usually avoid them as I always think they leave too much room for error. I dont know how many complaints you have or how complicated the complaint number may be.
    Normally I'd have a combobox on the form to jump to a record. It has the advantage of ensuring a correct number is entered and it will find as you type.

    That said, there was a recent thread about TaskBoxes and I've been trying to utilize them as a learning exercise.

    Here's a Taskbox procedure that uses a find first routine.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  2. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  3. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  4. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  5. Replies: 0
    Last Post: 01-11-2012, 12:34 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