Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182

    Trying to Make a Search function for a SplitForm

    Hello.

    I have a SplitForm. I want to create a search function to search for certain records in the SplitForm. I believe this must be done using "ApplyFilter." But everytime I have tried, I am being told I incorrectly input my WHEREIS function. I want my search function to be a field linked to a command button. If I type in "Africa" in my search field, I want to get a return of all the records that reference Africa in my Split Form.

    This is the basic thing I need help with. I will eventually be making this a little more complicated. But baby steps...

    THanks!!!

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    To set a filter on a form (it seems here that it would be in the OnClick event of the ApplyFilter button):
    Me.Filter="fieldname='" & Me!textfieldname & "'"
    Me.FilterOn=True
    Me.Requery

    Note - for text fields you need to include the single quotes, for number fields these would be omitted.

  3. #3
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    Thank you. I tried inputing the code so it looks like this:

    Private Sub btnSearch_Click()
    Me.Filter = "keyword='" & Me!Country & "'"
    Me.FilterOn = True
    Me.Requery
    End Sub



    However, it is still not working. When I try typing in a word, a popup box opens asking me to enter parameter value. If I type the word again, I am taken to a blank SplitForm.

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You show code from the button, but the error message is coming from the search field? Two different areas.

  5. #5
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    Click image for larger version. 

Name:	1.png 
Views:	12 
Size:	30.4 KB 
ID:	27295
    The image above if my main SplitForm. I typed in Nigeria in the "keyword" field. Then I pressed search.

    Click image for larger version. 

Name:	2.png 
Views:	12 
Size:	35.0 KB 
ID:	27296
    I then am told to enter the parameter value (as seen in picture two.) So I type in Nigeria again, but then I am told to enter parameter value again and again and again.


    Click image for larger version. 

Name:	3.png 
Views:	12 
Size:	36.5 KB 
ID:	27298
    Lastly, I am given a Microsoft Visual Basic Run Time Error 3021.

    Click image for larger version. 

Name:	4.png 
Views:	12 
Size:	17.7 KB 
ID:	27299
    When I click "debug" I see this.
    Attached Thumbnails Attached Thumbnails 3.jpg  

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The field "Keyword" is not being recognized by Access. This field must be somewhere on the form (it is not on any of your screen prints above). Should the field name be "Country" instead?

  7. #7
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    "Keyword" is the name of the field where I type in the word I want to filter. In the pictures above, I typed in "Nigeria" in the keyword field.

    When I hit the command button, I want to return all incidents where Nigeria is identified as a "Country" (The field in between Region and Category)

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The code for the filter that I gave you in post #2 says - filter all records where the "fieldname" (on the table) is equal to the fieldname on the form. So the field name on the table is "Country" and the field name on the form (where you type in Nigeria) is ??? Keyword? If so, post #3 the fieldnames are reversed.

  9. #9
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    Click image for larger version. 

Name:	5.png 
Views:	12 
Size:	67.5 KB 
ID:	27303
    I tried updating the info in the code. I am not getting an error, but I am also not having my results filtered

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Do you know how to debug? If you put a stop in the code and then when you click the button hold the mouse over the "Me!Keyword" and see what value it has. Either that or add a line saying "Debug.Print Me!Keyword"

  11. #11
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    I am sorry. But I am not sure about how to debug or what to do at all

  12. #12
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Add a line of code to your button click - after Me.Filter=
    add the line: Debug.Print Me!Keyword
    Then click on the button
    then go to VBA
    At the bottom there should be a line - if not, go to View>Immediate Window
    the value of the keyword will be shown there.

    I am trying to make sure that there is a proper value in the filter field

  13. #13
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    Click image for larger version. 

Name:	6.png 
Views:	13 
Size:	10.6 KB 
ID:	27305I attached the picture
    And btw, I really really appreciate this help

  14. #14
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Presumably Keyword is an Unbound Control on the Form...try replacing the Bang in "Me!Keyword" with a Dot "Me.Keyword"

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  15. #15
    zashaikh is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    182
    I replaced Debug.Print Me!Keyword with Debug.Print Me.Keyword


    Now in the "Immediate" Window, it just says "Null"

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

Similar Threads

  1. Replies: 2
    Last Post: 07-06-2012, 08:35 PM
  2. From subform to splitform
    By webisti in forum Access
    Replies: 1
    Last Post: 02-13-2012, 10:26 AM
  3. Replies: 4
    Last Post: 01-12-2012, 11:56 AM
  4. Question about Northwind Splitform Controls
    By ajetrumpet in forum Forms
    Replies: 2
    Last Post: 09-13-2010, 09:08 PM
  5. How to make use of Function Keys (F1, F2 etc)
    By rommelgenlight in forum Access
    Replies: 1
    Last Post: 05-15-2009, 02:51 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