Results 1 to 13 of 13
  1. #1
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103

    Search code direct in Search Form not subform

    Hi
    I have a little query
    I have a search form where I have a subform name SearchEN associate with query but Now I want to use search without subform
    In subform my search form search text code is:-



    Private Sub search_Change()
    DoCmd.Requery "SearchEN subform"
    End Sub
    Its work perfect but I want to work without subform what code should be?
    I have use
    Private Sub search_Change()
    DoCmd.Requery
    End Sub
    but its not working its give the error
    I have also tried the Search form name "SearchForm" but its not working

    Help required.....

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    if you have a search box, it would run this code:


    Code:
    sub txtSearch_afterupdate()
    If IsNull(txtSearch) Then
      Me.FilterOn = False
    Else
      Me.Filter = "[CCode]='" & txtSearch & "'"
      Me.FilterOn = True
    End If
    end sub

    but youd need a way to tell the form to search in 2 different places,
    1 for the master form
    1 for the subform

  3. #3
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Sorry I am searching in Master Form on change function in only single search box on query based
    Experiment2.zip
    Its my file I just want to ignore the subform and want to work in Master form
    Thanks

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,121
    Can you have a look if that is what you want?

    Cheers,
    Vlad
    Attached Files Attached Files

  5. #5
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by Gicu View Post
    Can you have a look if that is what you want?

    Cheers,
    Vlad
    You are right but sorry bro I want onchange filter not after update.
    I just want to change the said code in subform to Master form
    If I used this code on subform its work perfect
    Private Sub search_Change()
    DoCmd.Requery "SearchEN subform"
    End Sub
    but if I use Master form its give error
    I want to change this code to enable for master form on change function instead of afterupdate.
    Thanks

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,121
    Can you post a sample db, you don't make much sense as the file you posted does not have a subform. OnChange fires with every keystroke and it is usually not ideal to apply a filter like that. With a few records your performance might seem OK but once your table grows it will definitively have an impact. Also, with the OnChange you will need to use the text property as the control value has not yet been saved (as it is the case for the AfterUpdate).

    Cheers,
    Vlad

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,121

  8. #8
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Experiment2-davegri-v01.zip
    This is what I came up with.
    Had to add hidden textbox [tKey] to accumulate the keystrokes.
    Added a tempvar and used it in the query search criteria

    The big problem was caused by the requery of the form after each search textbox change.
    Solution still has a problem of not recognizing backspace in the search textbox.

  9. #9
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Thanks to cooperate
    Lets see !!
    Experiment_Search.zip
    Lets see this DB There are two forms named "SearchForm_Ok" Its working perfect its based on subform! Right the code is (DoCmd.Requery "SearchEN subform")
    Now the second form is "SearchForm_2" its master form which is linked with query!! There is problem. The code above not work on change!!!!
    I want to adjust the code of this form on "Change" where I want to get result as its shown in "SearchForm_Ok"
    Note: I dont want "afterupdate" Code I want "change" code
    Now I think its much easy to understand my problem.
    Thanks for quick reply

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Experiment2-davegri-v02.zip
    I believe v02 solves the problem 100%.
    I had time to resolve the backspace problem this morning.

  11. #11
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by davegri View Post
    Experiment2-davegri-v02.zip
    I believe v02 solves the problem 100%.
    I had time to resolve the backspace problem this morning.
    Thanks a lot.
    can this process also work for two search boxes if made changes or just for single?

  12. #12
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    can this process also work for two search boxes if made changes or just for single?
    Can you explain why you would need 2 search boxes? The search textbox in my supplied DB searches both the Surety Name and the CNIC.

  13. #13
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    I want multi search as you type form so I think if Its can extend to multi search boxes then it would better form me
    however thanks a lot for your help
    My problem solved

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

Similar Threads

  1. Replies: 5
    Last Post: 05-09-2015, 04:47 PM
  2. Replies: 3
    Last Post: 01-04-2015, 06:09 PM
  3. Replies: 3
    Last Post: 08-22-2012, 03:28 AM
  4. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  5. Replies: 4
    Last Post: 01-11-2010, 11:41 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