473,486 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I reactivate a button on an Access form after Filter by Form?

3 New Member
I may be about to surrender on this...I've asked in other forums and am not getting the answer I thought I'd get.

I'm creating an Access database that I ultimately want to compile into a stand-alone app. As part of this, I have a dashboard that opens when the database is opened, with various buttons to perform various tasks, most of which involve going to one part of the database or another. My primary table has 32 fields, and will ultimately have over a thousand records. Because any of the fields and any combination of them may need to be used for search criteria, I have set the button on the dashboard that allows one to search for a record and the one to edit a record to open their corresponding forms in Filter by Form mode. This works really well...the forms open just like I want, allowing users to type information into any control, and upon clicking Toggle Filters in the Home ribbon, exactly the subset of records being sought materialize as if by magic.

The challenge is this: I want to add a button to the form that runs the Toggle Filters process, so that I can make my app not have any of the Access ribbons in it. Unfortunately, when the form opens in Filter by Form mode, all buttons are greyed out and deactivated. On another help forum I posted this question and had someone say that it related to focus, but in spite of repeated questioning no one has been forthcoming there as to what commands are necessary to return the focus so that the button can be clicked. I need to know what the code is that I need to enter and where to enter it (i.e., in the Find Record button's On Click event or in the form's On Filter event).

Thank you in advance for any and all assistance.
Mar 12 '15 #1
3 2509
jforbes
1,107 Recognized Expert Top Contributor
When using the FilterByForm functionality, it's pretty much all or nothing with the way Access expects you to use it. I'm not a big fan of FilterByForm. It looks good initially, but loosing the command button functionality is a big problem that can't be circumvented. Secondly, there is no way out of the FilterByForm with out using the Ribbon or Right-clicking the Form. Well, you can set focus on the Form and cause an error, but that would require code being started from someplace other than the Form that is being Filtered.

To address your frustration as to why you can't click on the button on your Form... When you click on the FilterByForm command on the Ribbon Access hides your current Form then creates a brand new Form based on the Form you were just on. This brand new Form is not a copy of your Form, but different Form altogether that impersonates the Original Form. Like a Pod Person =)

This Pod Person Form doesn't have any events of the Original Forms and the Buttons are just for show. They aren't just disabled, they do not have anything behind them. They are the Soulless eyes of the Pod People Form. I realize I'm taking this too far, but I'm having a lot of fun entertaining myself.

For what you are wanting to do, I think you have the hard decision to rely on the Ribbon (or custom Ribbon) or create a new Filtering Method.
Mar 13 '15 #2
Hagridore
3 New Member
I'm probably going to create a filter form. But your reference to focus makes me wonder. I have the form being opened in FilterByForm mode when I click a button on the main dashboard. This button (actually there're two with this purpose, each opening their own form, one in read only mode for finding and one in edit mode for, well, editing :-) has the code in it to open the form in that mode. Would this be where the focus code would be added? What is the code so I can check it out?
Mar 13 '15 #3
jforbes
1,107 Recognized Expert Top Contributor
I'm curious how you are opening the Form in FilterByForm Mode. Maybe there is something about how this is being accomplished that can we can work with. So, I'll trade you code.

OK, this code is a Hack. It is not good coding at all, but you asked for it... The idea is that when the Doppelganger Form gets focus and traps an error, it causes Access to Destroy the Doppleganger. I'm not sure if that is exactly what is happening, but it is how it acts.
Place this code on a the Form that you want to use the FilterByForm functionality. You'll also need to add a button to go along with it, if you don't already have one:
Expand|Select|Wrap|Line Numbers
  1. Private nFilterByForm As Boolean
  2. Public Sub removeFilterByForm()
  3.     On Error Resume Next
  4.     If Screen.ActiveForm.Name = Me.Name And nFilterByForm Then DoCmd.RunCommand acCmdCloseWindow
  5. End Sub
  6. Private Sub cmdFilterByForm_Click()
  7.     nFilterByForm = True
  8.     DoCmd.RunCommand acCmdFilterByForm
  9. End Sub
  10. Private Sub Form_Current()
  11.     nFilterByForm = False
  12. End Sub
Then on another Form, like your switchboard, create a button with this code that turns off the Filtering (use your own Form Name):
Expand|Select|Wrap|Line Numbers
  1. Private Sub openTestFilterByForm_Click()
  2.     Dim sFormName As String
  3.     sFormName = "TestFilterByForm"
  4.     If isLoaded(sFormName) Then
  5.         Forms(sFormName).SetFocus
  6.         Forms(sFormName).removeFilterByForm
  7.     Else
  8.         DoCmd.OpenForm sFormName
  9.     End If
  10. End Sub
This is a function that is used to see if a Form is loaded that I use often, I included it because it was easier for me that way:
Expand|Select|Wrap|Line Numbers
  1. Function isLoaded(ByRef sFormName As String) As Boolean
  2.     ' Determines if a Form is loaded
  3.     Dim i As Integer
  4.  
  5.     isLoaded = False
  6.     For i = 0 To Forms.Count - 1
  7.         If Forms(i).FormName = sFormName Then
  8.             isLoaded = True
  9.             Exit Function
  10.         End If
  11.     Next
  12. End Function
Mar 14 '15 #4

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

Similar topics

1
7829
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
0
2056
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...
2
11483
by: Jimi Ffondu | last post by:
Hi there - it's pretty simple, and I'm an idiot. I'm not a developer, I just seem to have landed in this job building this Access database - I've got two days to make it work... aaahh! 1) ...
3
1437
by: Steven Little | last post by:
I have a button on one screen that opens another form. If I click it then the form opens but the fields are all blank. I look at it in Design view and the filter shows the proper key. If I...
4
6575
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...
2
4247
by: patriciashoe | last post by:
Greeting All I have several public variables which I use to build a filter string that I would like to use when I open a form and several associated sub forms. I have set the value of the combo...
2
1473
by: Salochin | last post by:
Hay all, Try not to laugh to loud at my attempt of vb, hehe, im totally newbie at this stuff but trying all the same I have a rough idea what im doing but im stuck on a cmd button I want it to...
7
5268
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...
0
1411
by: JpjVB | last post by:
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...
3
2843
by: rwalle | last post by:
Hi I have a strange problem in a form filter my set up is as follows there is a form named "InAlarmResumeForm" that has a subform "AlmActiveQrySform" the form has Textboxes with datapicker enabled...
0
6964
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...
0
7175
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
6842
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
5430
agi2029
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,...
1
4864
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
4559
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
3069
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...

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.