Hi,
I've developed a form filter that produces a number of hours budgeted by employee/location/practice group/experience level and date available using some Allen Browne code. I have two command buttons, cmdFilter and cmdFilterAvail. cmdFilter filters the form based on the criteria selected via my list and text box filters. One of the fields in the form, text51 has a control source:=IIf([clientname]="Unassigned Time",[BudgetedHours],Null)
On click, cmdFilter filters my results but also shows the null values present in the data set where clientname <> "Unassigned Time". I'd like cmdFilterAvail to be able to keep the filters applied, but then narrow my data set to NON-NULL text51 values thereby showing only employees with available time.
Code for frmFilterAvail is identical to frmFilter and needs to have the NON-NULL piece added and I don't know how to do it...Help would be greatly appreciated. - Private Sub cmdfilteravail_Click()
-
'Purpose: Build up the criteria string from the non-blank search boxes, and apply to the form's Filter.
-
'Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
-
we remove the trailing " AND " at the end.
-
' 2. The date range works like this: _
-
Both dates = only dates between (both inclusive. _
-
Start date only = all dates from this one onwards; _
-
End date only = all dates up to (and including this one).
-
Dim strWhere As String 'The criteria string.
-
Dim strExperienceLevel As String
-
Dim strPracticeGroup As String
-
Dim strLocation As String
-
Dim varSelected As Variant
-
Dim lngLen As Long 'Length of the criteria string to append to.
-
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates in a JET query string.
-
-
'***********************************************************************
-
'Look at each search box, and build up the criteria string from the non-blank ones.
-
'***********************************************************************
-
'Text field example. Use quotes around the value in the string.
-
If Me.txtFilterExperienceLevel.ItemsSelected.Count > 0 Then
-
For Each varSelected In Me.txtFilterExperienceLevel.ItemsSelected
-
strExperienceLevel = strExperienceLevel & ",""" & Me.txtFilterExperienceLevel.ItemData(varSelected) & Me.txtFilterExperienceLevel & """"
-
Next varSelected
-
strExperienceLevel = Mid(strExperienceLevel, 2) 'REMOVES LEADING COMMA
-
strWhere = strWhere & "([ExperienceLevel] IN (" & strExperienceLevel & ")) AND "
-
End If
-
-
If Not IsNull(Me.txtFilterExperienceLevel) Then
-
strWhere = strWhere & "([ExperienceLevel] = """ & Me.txtFilterExperienceLevel & """) AND "
-
End If
-
-
If Me.txtFilterPracticeGroup.ItemsSelected.Count > 0 Then
-
For Each varSelected In Me.txtFilterPracticeGroup.ItemsSelected
-
strPracticeGroup = strPracticeGroup & ",""" & Me.txtFilterPracticeGroup.ItemData(varSelected) & Me.txtFilterPracticeGroup & """"
-
Next varSelected
-
strPracticeGroup = Mid(strPracticeGroup, 2) 'Removes leading comma
-
strWhere = strWhere & "([PracticeGroup] IN (" & strPracticeGroup & ")) AND "
-
End If
-
-
If Not IsNull(Me.txtFilterPracticeGroup) Then
-
strWhere = strWhere & "([PracticeGroup] = """ & Me.txtFilterPracticeGroup & """) AND "
-
End If
-
-
If Me.txtfilterlocation.ItemsSelected.Count > 0 Then
-
For Each varSelected In Me.txtfilterlocation.ItemsSelected
-
strLocation = strLocation & ",""" & Me.txtfilterlocation.ItemData(varSelected) & Me.txtfilterlocation & """"
-
Next varSelected
-
strLocation = Mid(strLocation, 2) 'Removes leading comma
-
strWhere = strWhere & "([Location] IN (" & strLocation & ")) AND "
-
End If
-
-
If Not IsNull(Me.txtfilterlocation) Then
-
strWhere = strWhere & "([Location] = """ & Me.txtfilterlocation & """) AND "
-
End If
-
-
'Another text field example. Use Like to find anywhere in the field.
-
If Not IsNull(Me.txtFilterMainName) Then
-
strWhere = strWhere & "([EmployeeName] Like ""*" & Me.txtFilterMainName & "*"") AND "
-
End If
-
-
'Date field example. Use the format string to add the # delimiters and get the right international format.
-
If Not IsNull(Me.txtStartDate) Then
-
strWhere = strWhere & "([BudgetDate] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
-
End If
-
-
'Another date field example. Use "less than the next day" since this field has times as well as dates.
-
If Not IsNull(Me.txtEndDate) Then 'Less than the next day.
-
strWhere = strWhere & "([BudgetDate] < " & Format(Me.txtEndDate + 1, conJetDate) & ") AND "
-
End If
-
-
'***********************************************************************
-
'Chop off the trailing " AND ", and use the string as the form's Filter.
-
'***********************************************************************
-
'See if the string has more than 5 characters (a trailing " AND ") to remove.
-
lngLen = Len(strWhere) - 5
-
If lngLen <= 0 Then 'Nah: there was nothing in the string.
-
MsgBox "No criteria", vbInformation, "Nothing to do."
-
Else 'Yep: there is something there, so remove the " AND " at the end.
-
strWhere = Left$(strWhere, lngLen)
-
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
-
'Debug.Print strWhere
-
-
'Finally, apply the string as the form's Filter.
-
Me.Filter = strWhere
-
Me.FilterOn = True
-
End If
-
End Sub
0 1416 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike O. |
last post by:
MS Access 2003 "filter by form" has drop down lists that allow the
user to select values for each field to filter by. However, once some
values are selected,the remaining dropdown lists remain the same and
aren't progressively filtered to reflect the selections already made
in other fields. This can be very tedious when filtering a large
datasheet. Unlike Access, the MS Excel autofilter has automatic
progressive filtering of value...
|
by: Nothing |
last post by:
I have a form that has a Tab Control on it. On one of the tab control
pages, there are only 3 pages, is a combo box based on a field called
departments in a table.
When the user selects one of the departments from the combo box I want a
sub-form to open on the tab control page based on the department
selected.
The sub-form is based on a query that pulls all employee data, so if a
user selects admissions, I want the subform to open and...
|
by: wecka |
last post by:
Hello All,
Does any one know how to use the form filter in Access to provide partial match?
When you choose to "form filter," all text boxes will convert to combo boxes where you can choose from the already stored data in the corresponding tables. But for example I want to match all records containing the word John (assume it is a name field).
If there is a way to do this, it will save my life from having to write a big chunck of SQL code...
|
by: Henrootje |
last post by:
Hello there!
I have a piece of code in a module (function) that constructs a
filter.
But now I run into a problem.....
It seems that I can only set a filter form a module if I open the form
in design mode..............
(that is, if changing the filter from a module / called function)
But that means any other changes I made on the form (such as f..e. the
|
by: phill86 |
last post by:
Hi,
I have a form that I have applied a filter to by using combo boxes which works fine.
Is there a way to apply that filter to the forms underlying query
Here is the code that I use to filter the form
On Error GoTo Error_EquipFilter
| |
by: phill86 |
last post by:
Hi,
I am filtering a report using the form filter with the following code
DoCmd.OpenReport "report1", acViewReport, , Me.filter
Which works fine untill I filter the form on one of the fields which is a lookup field
and I get the enter parameter value box which is looking for the Assetdetails.details field which contains the following text for some reason it has put Lookup_ at the front of the field
|
by: whkoh |
last post by:
I have two tables: Customer and Project with primary keys Customer ID and Project ID respectively.
A third table (Involvement) is the intersection table storing Customer ID and Project ID as foreign keys.
I need to select Project.* given Customer..
So far my query is
SELECT Project.*
FROM Project INNER JOIN (Customer INNER JOIN Involvement ON (Customer. = Involvement.) AND (Customer. = Involvement.)) ON (Project. = Involvement.) AND...
|
by: Obenash |
last post by:
Is it possible to filter a data entry form with multiple subforms. I have a form that is used to enter data into the database and the form has multiple subforms and I wanted to filter it to make it easier to move from one subform to another.
If it is possible, I will need help on how to do that. Thanks in advance.
Obenash
|
by: jsneed |
last post by:
I have a database that is going pretty good. The only problem I have been having is using a form to filter a table by description. In the table I have Part Number, description, vendor, utilized on, min, max, and ex. I want to be able to have my form filter the table by using the description, but I don't want the user to have to type in the complete description. If they are looking for a part number and happen to know it is some kind of 2" pipe,...
|
by: munkee |
last post by:
Hi all,
I am using Allen's excellent form filter script to filter the results from a query.
I would now like to add some further functionality. How do I go about displaying say the top N costs where in my search form I would have a drop down to select the N value and use radio buttons to select the field the top N should be run against (e.g. cost).
Thanks for any help in advance my code is as follows:
Option Compare Database
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |