473,473 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Allen Browne AutoFilter

Follow Up question to the below posted by Allen Browne on 02/06/2005 -
Could something like this work for a form that has a subform and the
subform is a datasheet?

__________________________________________________ _____________________

Re: Multiple Sort in a Continuous Form - Similiar to AutoFilter

06 Feb 2005 06:21
Allen Browne

Okay, so you want to create a string that adds in the value of all the
non-blank combos.
This example is set up so that it creates a filter from any of the combos
that have a value. It tacks an " AND " on the end, so it's easy to add as
many as you wish. Then at the end it chops off the trailing " AND ", and
applies the filter.

You can code it in one of the combos, and then call the code from the other
combos to the filter gets applied as soon as any combo is updated.

Private Sub Combo49_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then Me.Dirty = False 'Save first

If Not IsNull(Me.Combo49) Then
strWhere = strWhere & "([IPT] = '" & Me.Combo49 & "') AND "
End If

If Not IsNull(Me.Combo83) Then
strWhere = strWhere & "([Tier5] = '" & Me.Combo83 & "') AND "
End If

'etc for other combos.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lenLen > 0 Then
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn True
Else
MsgBox "No criteria."
End If
End Sub

Private Sub Combo83_AfterUpdate()
Call Combo49_AfterUpdate
End Sub

Note that this example assumes:
- All these combos are unbound (for filtering only), and
- IPT, Tier5, etc are all Text type fields. Remove the extra quotes for
number fields.

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
1 2379
If the main form is bound and you are wanting to filter the main form, then
yes, it will work exactly as indicated.

If you want to apply all the filter choices the filter to the subform
instead of the main form, it will be the same until you get to the lines:
Me.Filter = strWhere
Me.FilterOn True
Replace those two with lines that filter the subform instead, i.e.:
Me.[NameOfYourSubformControlHere].Form.Filter = strWhere
Me.[NameOfYourSubformControlHere].Form.FilterOn = True

If you are wanting to filter the main form based on values that are in the
subform, see:
Filter a Form on a Field in a Subform
at:
http://allenbrowne.com/ser-28.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Steven Britton via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message
news:06******************************@AccessMonste r.com...
Follow Up question to the below posted by Allen Browne on 02/06/2005 -
Could something like this work for a form that has a subform and the
subform is a datasheet?

__________________________________________________ _____________________

Re: Multiple Sort in a Continuous Form - Similiar to AutoFilter

06 Feb 2005 06:21
Allen Browne

Okay, so you want to create a string that adds in the value of all the
non-blank combos.
This example is set up so that it creates a filter from any of the combos
that have a value. It tacks an " AND " on the end, so it's easy to add as
many as you wish. Then at the end it chops off the trailing " AND ", and
applies the filter.

You can code it in one of the combos, and then call the code from the
other
combos to the filter gets applied as soon as any combo is updated.

Private Sub Combo49_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then Me.Dirty = False 'Save first

If Not IsNull(Me.Combo49) Then
strWhere = strWhere & "([IPT] = '" & Me.Combo49 & "') AND "
End If

If Not IsNull(Me.Combo83) Then
strWhere = strWhere & "([Tier5] = '" & Me.Combo83 & "') AND "
End If

'etc for other combos.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lenLen > 0 Then
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn True
Else
MsgBox "No criteria."
End If
End Sub

Private Sub Combo83_AfterUpdate()
Call Combo49_AfterUpdate
End Sub

Note that this example assumes:
- All these combos are unbound (for filtering only), and
- IPT, Tier5, etc are all Text type fields. Remove the extra quotes for
number fields.

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Don Leverton | last post by:
Hi Folks, I'm still in the process of rewriting my Parts Inventory application, and still using good old Access97 to do it. I'm attempting to modify Allen Browne's code from:...
15
by: Jerry Alexander | last post by:
The Northwind Order Entry Application database is great! ----------------------------------------- But one thing is lacking: Real-time Stock Qty calculation!...
0
by: Amy B | last post by:
Hi, I am using the code below to dynamically build an html table and write it to excel an excel spreadsheet. This code works great except that I need the headers use AutoFilter on the headers,...
1
by: doug9149 | last post by:
Hello all, I've got some code I wrote using VBA for Excel that I'm trying to recreate using C#.NET. The code autofilters 1 entire column from 1 Worksheet from a Workbook and then appends this...
7
by: Swinky | last post by:
Mr. Browne's copy code on his web site has saved me. I have been struggling to copy a record with several related sub-form tables. I found code on his web site that copies a sub-form table,...
3
by: Photobug | last post by:
I have downloaded Allen Browne's function TableInfo() and am getting a ByRef Type Mismatch error when I try to execute it. I don't know if it is a reference problem or not, but my references for...
4
by: rnot | last post by:
Hello, I would like to paste data at a cell found by the Selection.Autofilter function. My two first columns hold a "scenario" and "replication" data. I would like upon running a macro to...
2
by: sara | last post by:
I use Allen Browne's Audit Trail code in everything I do and I love it. Recently, I've run into a problem I can't figure out. I have a database with about 35 lookup tables. I am creating an...
6
by: babamc4 | last post by:
I have a main form (mainformlung) with 5 subforms (followupacute, followuplate, biochemresults, haemresults and pftresults). I have copied Allen Browne's Audit Trail code (thanks to Allen Browne)...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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,...
0
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...
1
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...
0
tracyyun
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.