Results 1 to 11 of 11
  1. #1
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7

    Subform can't apply the filter

    Hi,



    I create a sub form with a search function, but as I wanted to search the defect the form can't apply the filter. How to I fix the problem according to the error occur?

    In my unbound form platform I also put another sub form but they all functioning well according to the sub form but not the sub form with the search function.

    Click image for larger version. 

Name:	search not workable.png 
Views:	20 
Size:	47.5 KB 
ID:	47321

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Without seeing your filtering code it is hard to give you a solution; seems like you do not reference the subform properly in your filtering; when embedded into a main form you need to fully reference it or have code in its own module and use Me.Filter.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7
    Quote Originally Posted by Gicu View Post
    Without seeing your filtering code it is hard to give you a solution; seems like you do not reference the subform properly in your filtering; when embedded into a main form you need to fully reference it or have code in its own module and use Me.Filter.

    Cheers,
    Hi,

    I can search things that I want to search on my sub form, but when I want to search on my main form the error occur.

    Click image for larger version. 

Name:	subform search.png 
Views:	18 
Size:	15.3 KB 
ID:	47325

    This is my apply filter macro on my sub from on my search button

    Click image for larger version. 

Name:	apply filter command.png 
Views:	18 
Size:	4.7 KB 
ID:	47326

    This is my code for the open form in my sub form

    Click image for larger version. 

Name:	code search log.png 
Views:	18 
Size:	49.8 KB 
ID:	47327

    Is there any mistake in my code that make my form cannot use the search function?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You have to start with the mainform?
    Forms!MainForm!SubformControl!Form.Control
    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

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7
    Quote Originally Posted by Welshgasman View Post
    You have to start with the mainform?
    Forms!MainForm!SubformControl!Form.Control
    Hi, may I know where do I put this command in my property sheet in my main form?

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You modify the existing macro to include the main form name between [Forms] and [sbfr_GIGsearchlog] in both places.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7
    Quote Originally Posted by Gicu View Post
    You modify the existing macro to include the main form name between [Forms] and [sbfr_GIGsearchlog] in both places.
    I already modify the macro as u suggested but the same error still occur

  9. #9
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Care to share how the modified macro looks like? We can't help you if we don't see what you have. A form's filtering or searching functionality will most likely be lost when the form is embedded within another, as Access will no longer recognize the form itself as being loaded. Have you had a chance to review the two links I've posted in post #5?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #10
    ctathrh is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2022
    Posts
    7
    Quote Originally Posted by Gicu View Post
    Care to share how the modified macro looks like? We can't help you if we don't see what you have. A form's filtering or searching functionality will most likely be lost when the form is embedded within another, as Access will no longer recognize the form itself as being loaded. Have you had a chance to review the two links I've posted in post #5?

    Cheers,
    Hi,

    Below is the modify macro, I added my form name [frm_HPCV25] in between [Form] and [sbfrm_GIGsearchlog], but the error still occur.

    [Defect] Like "*" & [Forms]![frm_HPCV25]![sbfrm_GIGsearchlog]![Text39] & "*" Or [Defect_Description] Like "*" & [Forms]![frm_HPCV25]![sbfrm_GIGsearchlog]![Text39] & "*"

    Other that the macro and all the information I give above, I did not have any code or macro related to this problem to show.

    I already review two links you have posted and highlighted, but as I really new to access I did not know where and how I can apply the information given in the links. If you have time some guidance from you will be much appreciated.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    That is because you have not addressed the form within the subform control.
    Look at the syntax that Vlad linked to and also my comment on the syntax more carefully.
    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

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

Similar Threads

  1. Apply Filter to SubForm
    By zashaikh in forum Forms
    Replies: 7
    Last Post: 02-01-2017, 07:51 PM
  2. Apply Filter to Subform on Main Unbound Form
    By StuW in forum Programming
    Replies: 2
    Last Post: 10-20-2016, 10:02 AM
  3. Replies: 3
    Last Post: 02-23-2015, 11:57 AM
  4. Replies: 2
    Last Post: 02-25-2013, 10:47 AM
  5. Replies: 5
    Last Post: 10-06-2010, 07:28 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