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 
Filtering one form from anothe
Bill Carver 
      
2 years ago
I am trying to gather data on a popup form where I'd like to filter a form that is already open by whatever I choose in a combo box.

A variable is set to contain my choice.
then I'm trying to set from the one form the filter using the applyfilter command on a field named drivers!groups.   I need to use like because the imported data has other criteria in tihs field.  

This is what I have.  Where am I going wrong

Private Sub OKBtn_Click()
Dim Location
Location = LocationCMB
If Location = "All" Then
Location = ""
End If
MsgBox Location
DoCmd.ApplyFilter Form_Drivers!Groups Like Location
DoCmd.Requery [Drivers]
DoCmd.Close
End Sub

Sami Shamma  @Reply  
             
2 years ago
It is not possible to understand what you are trying to do.

Please show images.

Reword your question. "To set from the one form, the filter using the ApplyFilter command on a field named DriversGroups" does not make any sense.
Bill Carver OP  @Reply  
      
2 years ago
Ok... imagine if you will I have a table of addresses states in which the table displayed is on a form.  ON that form is just first last name, state

I want to make a nice clean interface to be able to filter all the people from a state on that form.  So on that form as a button saying "filter by state"  Clicking that button opens a new form created originally by going to create/forms/more forms/modial dialog.  It's essentially a shortcut to a smaller form with two buttons and a combo box.   I'd like to keep it this way since it's a very clean user interface element for this and other parts of my database.  

What I'd like the user to be able to do is click a button to bring up my select dialog (original form is open already)
Choose from the combo box on the form that pops up.
Have a script on the ok button that gathers the selection from the combo box.
goes back to the original form that launched the second form and set the filter
requery the original form so that it displays the data being filtered.
closes itself (the second modal form)


Adam Schwanz  @Reply  
           
2 years ago
While you can do this with something like this
Forms!FormName.Form.Filter = "State=NY"
Forms!FormName.Form.FilterOn=True


Are you sure you want to use a second form just for filtering? This sounds like somethingSearch Form 2.0 would handle very well.
Bill Carver OP  @Reply  
      
2 years ago
further comments.  The script in my original location was test to be sure the variable is working   My problem appears to be in the applyfilter on a form called drivers, a field called groups and filtering by the text in a string called location
Bill Carver OP  @Reply  
      
2 years ago
OK>.I've decided to walk before running.  My issue is the filter itself.  I've set up a combo box on the same form now with an after update event.  I just cannot get the filter to work when.  It shows red on compile or when I leave the line.    I'm sorry for the simplicity of the question, but looking at Microsoft help is not doing much to help here.  It's probably something very unintelligent that I"m doing but I'm baffled.  the line that appears to be failing is the DoCmd.AppyFilter line.

Is the issue that I cannot put the filter on a form this way?  Do I need to use that command on the queries I have in use?


Dim Location As String
Location = LocationCMB
If Location = "All" Then
Location = ""
DoCmd.Close
Else
DoCmd.ApplyFilter ,like location,[groups]
End If
Adam Schwanz  @Reply  
           
2 years ago
I've never used that docmd.applyfilter so I don't know, but your syntax looks wrong too. I'm sure it needs quotations at the very least. You also need to specify what field it's supposed to be filtering.

DoCmd.ApplyFilter ,"Location LIKE '*" & Location & "*'"

Use Me.Filter= or set it up like the Search Form 2.0

This might help too
Filter Combo
Kevin Robertson  @Reply  
          
2 years ago
Give this a go. If it doesn't work in your database please share some screenshots.

    Dim Location As String
    Location = LocationCMB
    
    If Location = "All" Then
        Location = ""
        DoCmd.Close
    Else
        DoCmd.ApplyFilter , "Location LIKE ""*" & Location & "*""", "groups"
    End If

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/1/2026 9:52:07 PM. PLT: 1s