473,790 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Apply Filter to Form & Subform

7 New Member
I have a Button on a form that filters on 2 fields using the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_NavyDue_Click()
  2. With Me
  3. .FilterOn = True
  4.     DoCmd.ApplyFilter , "[Branch] = 'NAVY' And [Count]>1"
  5.     Me.OrderBy = "[Person ID] DESC"
  6.     Me.OrderByOn = True
  7. End With
  8. End Sub
This works fine. However, I also want to filter on a field in a Subform when no record exists (or Is Null).

Subform Name: sub Rank Rate Location
Field Name: Duty Station

How do I make the Button apply a filter to the 2 fields on the Form as well as when there is no "Duty Station" on the Subform?
Nov 17 '09 #1
10 8721
ChipR
1,287 Recognized Expert Top Contributor
Not a lot to go on here, but perhaps you mean something like:
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[Branch] = 'NAVY' AND " _
  2.            & [Count]>1 AND " _
  3.            & [Duty Station] = " _
  4.            & Me![sub Rank Rate Location].Form![Duty Station]
  5. Me.FilterOn = True
Nov 17 '09 #2
NeoPa
32,579 Recognized Expert Moderator MVP
@edgalljr
What does this mean Ed?

You've told us nothing about records on the form yet you ask a question related to that. I'm sure if you can explain your requirement a little more clearly then we can help you to realise it.

Remember not to refer to anything in your database unless you have explained it first. Otherwise it's only possible to follow you using guesswork.
Nov 18 '09 #3
edgalljr
7 New Member
ChipR... Thanks for the response. When I run the script I get an "Enter Parameter Value" for both "Duty Station" and "Me!sub Rank Rate Location.Form!D uty Station"
Nov 19 '09 #4
ChipR
1,287 Recognized Expert Top Contributor
As NeoPa said, it's impossible to tell what you're doing. I took a guess, hoping that you would get something from the example. Perhaps you can rephrase your question so that we can understand.
Nov 19 '09 #5
edgalljr
7 New Member
This database contains 2 relevant tables. "tbl Master" contains all personal information (Person ID, Name, Branch, count, etc.) and a second table called "tbl Rank Rate Location" contains only Person ID, Rank, MOS Rating, and Duty Station. Person ID is common and links the two tables.

On the form I am working with, all of the information from "tbl Master" is displayed on the form "frm Master Tracker". The form also contains a sub form "sub Rank Rate Location" that shows the fields Rank, MOS Rating, and Duty Station.

I want a button on the form "frm Master Tracker" that, when clicked, will only show those records where the person is in a specific [Branch], has a [Count] >1, and does NOT have a Duty Station and will allow me to enter information into any field from either table / form.

Please let me know if I can clarify any further. Thanks for taking the time to respond!
Nov 19 '09 #6
ChipR
1,287 Recognized Expert Top Contributor
I understand much better now, thanks for the clafification.

It sounds like you want to apply a filter the to main form, then apply a separate filter to the subform to show only those records without a Duty Station. To do this from button code on the main form, you'd use (something like):
Expand|Select|Wrap|Line Numbers
  1. Me.[sub Rank Rate Location].Form.Filter = "[Duty Station] IS NULL"
  2. Me.[sub Rank Rate Location].Form.FilterOn = True
Nov 19 '09 #7
edgalljr
7 New Member
Actually, I want a single button on the main form. When I click the button, I want to know all of those people with No Duty Station. This will mean that either A) there is a linked record but Duty Station Is Null OR B) there is NO linked record.
Nov 19 '09 #8
ChipR
1,287 Recognized Expert Top Contributor
In that case, maybe you could filter the main form on:
Expand|Select|Wrap|Line Numbers
  1. NOT EXISTS 
  2.   (SELECT [Duty Station] 
  3.    FROM [tbl Rank Rate Location] 
  4.    WHERE [tbl Rank Rate Location].[Person ID] 
  5.        = [tbl Master].[Person ID])
Spaces in table and field names are a real pain.
Nov 19 '09 #9
edgalljr
7 New Member
That screaming you hear is me! That works perfectly and I think I now understand the concept! Thank you so much!
Nov 19 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9809
by: Andante.in.Blue | last post by:
Hi everyone! I was wondering if there is a away to use Access 97's build in filter-by-form function but restrict its effect to just the subform. I have a parent form that shows the major divisions of the company, and a subform that is linked so that it displays all the jobs within the division in the parent form. I also want the ability to filter the subform, so the users can pick out a bunch of common jobs easily. I did this using a...
7
6288
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals. I can do this the first time the form loads.
3
2770
by: Tony Williams | last post by:
Sorry to repost but I cannot work this out. Can anyone come up with a suggestion? I have a main form based on Table1. The form has a tab control of three pages. Each page has a subform based on a different table ie subform1 based on Table2, subform2 based on Table3 and subform3 based on Table4. I want the user to be able to use the Filter By Form facility in Access but this does not work when trying to select controls on the main form AND...
1
7597
by: Paulo Rodrigues | last post by:
Hello I have a main form and a subform. The subform contains several records wich have the field Date. Using a combobox that groups the dates, I intend to filter , in the subform,only this or that date, so I can see only the records wich have the same date. So far, I have the combo and the code Docmd.ApplyFilter "qryxyz" in the afterupdate procedure, but I can´t make it work. I have no idea if this possible to build .Can someone help ?
4
3577
by: MS | last post by:
I'm having trouble applying a filter to a subform. I create a String in a Module based on various selections on the form. Clicking a button on the "stand alone form" that changes the filter property string to the string from the module works fine. As soon as I put the form on the "main form" (thereby coverting it to a sub form) things no longer work. Of course the record source for the sub form is no longer a table or query, but the...
2
4034
by: Lenin Torres | last post by:
Hi everybody I have an Union Query that works fine. I used this query as the RecordSource for a Form. That Form is used as a subform in another form. Everything works fine, except for the "Filter by form" feature. When the user tries to use Filter by form a messagebox is displayed: "There are too many controls in this form to perform a filter by form", after that,when the user exit the Filter by Form mode, Access crash, displaying a...
0
1760
by: Stinky Pete | last post by:
Hi, The db I'm trying to update has a report form from which all other statistical forms and reports are selected/printed by dept, type, cost, number etc. The report form uses a date filter to generate the necessary data and you can also addtionally filter by by individual department/s, supplier/s if you so wish which is great However, I'm trying to develop an individual statistical form that for one subform uses the date filter as...
14
4092
by: Anja | last post by:
Hi everyone, I have a sub form that references a query to get the results. However, what I want to do is filter the results further based on a certain criteria. How can I tell the sub form to filter results based on a certain criteria. I tried using the Filter and OrderBy fields in the designer but they seem to have no affect!
1
6800
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes bits of code for different examples. I have one last thing to finish. I am trying to create a search form that will allow users to select criteria from multiple sources eg ,multi select list boxes , combo boxes. I have a subform showing all the...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.