Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272

    Search button to filter data

    Am trying to create a search button for my data.
    The current codes I have makes it possible to filter the data between date range and one drop down selection.

    I will like to add one more combo selection to the code to filter.



    Below are my current codes:

    “ strCriteria = "[MyDate] >= " & Format(Me.OrderDateFrom, "\#mm\/dd\/yyyy\#") & _
    " And [MyDate] <= " & Format(Me.OrderDateTo, "\#mm\/dd\/yyyy\#") & _
    " AND [IncomeType] LIKE '" & IIf(IsNull(Me.cboIncomeType), "*", Me.cboIncomeType) & "'"
    'task = "select * from ALL_INCOME where (" & strCriteria & ") order by [DATE]"
    DoCmd.ApplyFilter , strCriteria


    Assuming I want to add another combo called “pay_form”, how do I go about that?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The same way you added the first combo?

    Review http://allenbrowne.com/ser-62.html
    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
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by June7 View Post
    The same way you added the first combo?

    Review http://allenbrowne.com/ser-62.html
    Can you demonstrate for me?
    Because I picked the line I used to add the first combo and modified the details to fit the new fields. But the whole line was red, meaning the code is wrong.

    Currently having issues with my pc. Would have have copied the codes for you see it yourself.

    Would be glad if you could help me out

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    The AllenBrowne tutorial has all the demonstration you should need. Even has a sample db you can download. I am not going to try replicating in this thread.

    I have never used the DoCmd.ApplyFilter method.
    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.

  5. #5
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by June7 View Post
    The AllenBrowne tutorial has all the demonstration you should need. Even has a sample db you can download. I am not going to try replicating in this thread.

    I have never used the DoCmd.ApplyFilter method.
    Am not so good with the vba that’s why I needed you to help me with the code so I can easily insert them to fix the issue.

    Have gone through the link you sent and the understanding isn’t just coming

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Quote Originally Posted by Emmanuel View Post
    Am not so good with the vba that’s why I needed you to help me with the code so I can easily insert them to fix the issue.

    Have gone through the link you sent and the understanding isn’t just coming
    Can you post a copy of the db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Bob Fitz View Post
    Can you post a copy of the db
    That will be a little difficult currently because I have issues with my computer. Will try and upload once I fix it

  8. #8
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Whilst I try to upload the database, this is a shot of where I had the error. Any suggestions will be will be appreciated.
    Attached Thumbnails Attached Thumbnails 93766D0F-9F67-43CA-B1E5-0F6899D77239.jpg  

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Missing & _ at end of cboIncomeType line.
    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.

  10. #10
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by June7 View Post
    Missing & _ at end of cboIncomeType line.
    So something like me.cboIncometype1) & _ "'"

    If that’s the case, then have tried that already and it didn’t work

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    No. See how the first 3lines of code in your graphic end with & _
    Since the line in red (error) is a continuation, then line 3 needs the same & _
    Line continuation

    You should copy the actual code and paste it here in the forum. I'm not following the logic of your LIKE construct.

  12. #12
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by orange View Post
    No. See how the first 3lines of code in your graphic end with & _
    Since the line in red (error) is a continuation, then line 3 needs the same & _
    Line continuation

    You should copy the actual code and paste it here in the forum. I'm not following the logic of your LIKE construct.
    Your suggestion worked
    Thanks so much

  13. #13
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    A having another challenge trying to apply the filter.
    Please any suggestions to fix it?
    Attached Thumbnails Attached Thumbnails 95421C7C-B941-487E-BA31-8287E4060E43.jpg  

  14. #14
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Have been able to find a fix. I noticed the criteria wasn’t set properly. Thanks to you all

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-04-2019, 07:17 PM
  2. Replies: 1
    Last Post: 11-30-2016, 03:41 AM
  3. Subform Data Entry Button - Search Button
    By thaBadfish in forum Forms
    Replies: 11
    Last Post: 06-23-2015, 03:14 PM
  4. Replies: 5
    Last Post: 01-24-2015, 11:49 AM
  5. Replies: 12
    Last Post: 03-22-2012, 02:48 AM

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