I have a Button on a form that filters on 2 fields using the following code: - Private Sub cmd_NavyDue_Click()
-
With Me
-
.FilterOn = True
-
DoCmd.ApplyFilter , "[Branch] = 'NAVY' And [Count]>1"
-
Me.OrderBy = "[Person ID] DESC"
-
Me.OrderByOn = True
-
End With
-
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?
10 8721 ChipR 1,287
Recognized Expert Top Contributor
Not a lot to go on here, but perhaps you mean something like: - Me.Filter = "[Branch] = 'NAVY' AND " _
-
& [Count]>1 AND " _
-
& [Duty Station] = " _
-
& Me![sub Rank Rate Location].Form![Duty Station]
-
Me.FilterOn = True
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.
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"
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.
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!
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): - Me.[sub Rank Rate Location].Form.Filter = "[Duty Station] IS NULL"
-
Me.[sub Rank Rate Location].Form.FilterOn = True
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.
ChipR 1,287
Recognized Expert Top Contributor
In that case, maybe you could filter the main form on: - NOT EXISTS
-
(SELECT [Duty Station]
-
FROM [tbl Rank Rate Location]
-
WHERE [tbl Rank Rate Location].[Person ID]
-
= [tbl Master].[Person ID])
Spaces in table and field names are a real pain.
That screaming you hear is me! That works perfectly and I think I now understand the concept! Thank you so much!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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.
|
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...
|
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 ?
|
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...
| |
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...
|
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...
|
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!
|
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...
|
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,...
|
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...
| |
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...
|
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,...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |