Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Multiple Queries in a Single Form
Leo Rivera 
   
4 months ago
I created a form that where multiple queries are embedded at reform. The main query has a filter where you require to enter a year number (e.g. 2026). I the same form there is a subform wish appoint to another query this query also has a filter. Therefore when I open the form the windows for the first filter is open and when I enter the info the next filter is open too. And in this stage I do not need the second filter is running.  My question is: I have to do to avoid the second query filter is running What code I have to do to avoiding the second filter is running?
Donald Blackwell  @Reply  
       
4 months ago
Let me see if I understand what you are asking:

You have a form which is filtered based on a query. That form has a subform that is also filtered based on another query.

Are you asking how to make the subform not filtered when it initially loads, or how to not even load the subform until some action is taken in the main form?
Leo Rivera OP  @Reply  
   
4 months ago
Yes
Donald Blackwell  @Reply  
       
4 months ago
If you're wanting it to load all records until you enter the year, then just have the query that the subform is based upon show all the records (remove the filter from the query), then in the After Update event of the year field, set the filter of the subform's form and turn the filter on. This would be done w/ VBA:

DetailsPrivate Sub YEARFIELD_AfterUpdate()

     DIM S as String

     If Not IsNull(YEARFIELD) Then
          S = "Year=" & YEARFIELD
     Else
          S = ""
     End If

     SUBFORM.Form.Filter = S
     SUBFORM.Form.FitlerOn = Not IsNull(YEARFIELD)

End Sub


Replace YEARFIELD with the name of the field you are getting the Year from. Replace SUBFORM with the name of your subform control. Replace "Year" in S with the field in the query you are looking at. If it's a date field, you'll need to adjust for that by wrapping YEARFIELD in hashtags (#) inside of quotes.
Donald Blackwell  @Reply  
       
4 months ago
Alternatively, if you just don't want the subform to load at all until a year is entered, then I would make the Source Object of the sub form blank initially and set the subform's visibility to no. Then, again in the After Update event of the Year field, set the Source Object and make the subform visible, again w/ VBA:

DetailsPrivate SUB YEARFIELD AfterUpdate()

     If IsNull(YEARFIELD) then
          SUBFORM.Form.SourceObject = ""
          SUBFORM.Visible = False
     Else
          SUBFORM.Form.SourceObject = "QUERYNAME"
          SUBFORM.Visible = True
     End If

End Sub


This assumes that the query gets its filter from the form. If not, you'll need to add the stuff from above.

The main issue is that if your subform is based on an already filtered query, you either have to change the filtering in that query on load or change the query itself. Here are some links that relate somewhat:

On Filter
Requery Subform

Richard has plenty of videos on Filtering, Subforms, and Queries, these are just a couple
Leo Rivera OP  @Reply  
   
4 months ago
Awesome! Thank you very much.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 7:45:18 AM. PLT: 0s