I have a form which, depending from where it is opened, is filtered. I wish to have a way to remove filter so one has access to all records, but it is important that once filter is removed it does not jump to first record (It is single form). Is there a way to reset filter and keep the current record in form?
I hope this makes sense..
9 4588
Hi, HyBry.
The following solution will work if you have visible control containing linked table primary key or other unique field.
form module -
Private blnFilterRemoved As Boolean
-
Private varID As Variant 'linked table unique field
-
-
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
-
-
If ApplyType = 0 Then 'filter is being removed
-
blnFilterRemoved = True
-
varID = Me.varID
-
'varID assumed to be a name of visible form control
-
'linked to varID table field
-
End If
-
-
End Sub
-
-
Private Sub Form_Current()
-
-
If blnFilterRemoved Then
-
blnFilterRemoved = False
-
Me.varID.SetFocus
-
DoCmd.FindRecord varID
-
End If
-
-
End Sub
-
Thanks for the replay.. and sorry that mine is so late.
I did not fully understand the code you gave me and I did not get it to work, but it lead me to a different way to get it sorted: -
Private Sub Form_Current()
-
If Me.FilterOn = True Then
-
Dim valFN As String
-
valFN = Me.FullName
-
Me.FilterOn = False
-
DoCmd.GoToControl "FullName"
-
DoCmd.FindRecord valFN
-
End If
-
End Sub
-
Does this seem OK or it can be problems in long run?
Hi, HyBry.
Did you test the code? It looks like it will remove filter immediately after setting but will move form focus to the first filtered record, provides just some kind of record search. Is that what you've actually wanted?
Hi FishVal,
Yes that is what I wanted, but only way I could find to do it was to use filter as it I am opening a new form.
The code is Ok but I'm not sure it is a best idea to put it in Form_Current.
Did you try to put the code to Form_Open or Form_Load event handler?
khmm... good idea... I did not try that..
Thanks... I am sure that will be much better... and maybe faster..
As I am still quite new to this it takes me some time to figure out where what should go. :D
I need a bit more help on this please....
So I use this -
If Me.FilterOn = True Then
-
Dim valFN As String
-
valFN = Me.FullName
-
Me.FilterOn = False
-
DoCmd.GoToControl "FullName"
-
DoCmd.FindRecord valFN
-
End If
-
in order to remove filter on the form in On_Load or On_Open events, and it works fine when the form is opened.
But if I click the button on the first form again, without closing target form first, it sets the filter again and as the form was already opened filter is not removed. I tried putting this in On_Current and that had different effect - it will work at first, when reloaded next time - no effect, reload again - filter removed, reload again - no effect and so on...
Any ideas how to solve this or the best bet is to make this modal (not preferred solution) so user is forced to close it?
Hi, HyBry.
The simplest answer is: close the form before open. -
DoCmd.Close acForm, "[Your form name]"
-
I wish I was as smart as You... it is so simple yet never entered my mind..
Thanks again :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
by: Terry |
last post by:
I have cerated a Form, ExamsFrm, which is used to input details of
exams taken at several Centres. It dosplays details from StudentTbl
and has a SubForm which displays details from ExamsTble.
I...
|
by: Nhmiller |
last post by:
I already have a report designed under Reports. When I use filtering in Forms
or Tables, I see no way to select that filtered list when I am in Reports, and
there appears to be no way to do the...
|
by: Ralph2 |
last post by:
Some time ago with a lot of help from this group I made a reasonably
successful database to keep track of our shop drawings. However the
searching mechanism is too complicated for the occasional...
|
by: mtermoul |
last post by:
Hi,
I'm trying to write an ASP.NET page using VS.NET 2003, Office 2003, Win 2000
but I keep gettin this error:
"The message filter indicated that the application is busy" this is the code....
|
by: Bob |
last post by:
I am in the process of upgrading an Access database to SQL Server (and
climbing that learning curve!). The wizard happily upgraded all the tables
and I can link to them OK using ODBC.
The...
|
by: bammo |
last post by:
MS Access 2003, Windows XP SP2, VBA
I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in...
|
by: BSTAFFORD |
last post by:
I need help.
I have a form with a 5 comboboxes. the form also contains a subform query with the saved records from those 5 combobox categories. What I'd like to happen is as a new record is...
|
by: vanlanjl |
last post by:
I have created a form that contain two combo boxes and two cmd buttons. The idea of the form is that the user will select a search parameter from each combo box then will click the first cmd button...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
| | |