Results 1 to 5 of 5
  1. #1
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186

    Filter a database based on a textbox info

    Hello everyone

    I have the next issue

    I want to filter a database based on the info typed into the text box, after this, clicking on the button search and filter the database...

    I have an issue in my code, because I know just how to filter it based on a field but not for all....


    The fields I have are: Batchnumber, ModelnumberID, OperadorID, Datet, TestResults, Units and Status

    My code is:

    Me.Requery
    Me.Filter = ""
    Me.FilterOn = False

    If Me.searchtxt <> "" Then

    Me.Requery

    'That's my issue:

    Me.Filter = "[*] like " & Chr(34) & "*" & searchtxt & "*" & Chr(34)

    'I know normally should be here the [*] = [Fieldnumber], but how must be established for all the fields?

    Me.FilterOn = True

    End If


    Thanks in advance for the support!!!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You want to apply the same parameter to multiple fields?

    You will have to repeat and concatenate the criteria for each field.

    These fields are different data types. LIKE and wildcard will not work properly for number and date types.
    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
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  4. #4
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186
    You were right! I've concatenated the criteria and it worked pretty good,

    Quick question

    If I had two textboxes and with date criteria 1: Startdatetxt and the second one EndDatetxt and a button Filtercmd and everytime when I click on the button it filters the info between the dates and on this info (filtered) I would like to apply the new searchcmd how could be defined since when I click on searchcmd it starts from the beggining and not for the new information filtered

    My code is this one, but it does not work

    Private Sub Filtercmd_Click()
    Me.Requery
    Me.Filter = ""
    Me.FilterOn = False

    If Me.StartDatetxt <> "" And Me.EndDatetxt <> "" Then

    Me.Requery

    Me.Filter = "Datet >= #" & StartDatetxt & "# And Datet <= #" & EndDatetxt & "#" & "And [ModelNumber] like " & Chr(34) & "*" & searchtxt & "*" & Chr(34) & "Or [BatchSer] like " & Chr(34) & "*" & Searchtxt & "*" & Chr(34) & "Or [OperatorNumber] like " & Chr(34) & "*" & searchtxt & "*" & Chr(34) & "Or [TotalResult] like " & Chr(34) & "*" & searchtxt & "*" & Chr(34)
    Me.FilterOn = True
    End If

    Thanks for the support!

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Did you explore the Allen Browne link posted by Steve?
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-05-2013, 10:09 PM
  2. Textbox displays info but can not edit.
    By Yiannis in forum Forms
    Replies: 3
    Last Post: 11-16-2012, 01:34 PM
  3. Filter and Sort a form based on TextBox Values.
    By Ramun_Flame in forum Programming
    Replies: 7
    Last Post: 10-28-2012, 06:53 AM
  4. Replies: 7
    Last Post: 10-13-2012, 10:53 AM
  5. Replies: 4
    Last Post: 07-07-2012, 07:14 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