Working in Access 2000... I have a form with records for every employee. I'd like to create two command buttons so a user can filter the form for either 'only current' or 'only former' employees. I applied the first filter ([Termination Date] Is Null) and created the first 'apply filter' command button (using the wizard), then cleared the filter, applied the second filter ([Termination Date] Is Not Null), and created the second command button. It changed the first button to apply the same filter as the second button.
How do I create two different filter options on the same form? Using the wizard, the event procedure that was created is:
Private Sub CmdCurrent_Click()
On Error GoTo Err_CmdCurrent_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
Exit_CmdCurrent_Click:
Exit Sub
Err_CmdCurrent_Click:
MsgBox Err.Description
Resume Exit_CmdCurrent_Click
End Sub
I don't understand enough of this to know how to change it.
Any ideas?
Angi
3 9013
Working in Access 2000... I have a form with records for every employee. I'd like to create two command buttons so a user can filter the form for either 'only current' or 'only former' employees. I applied the first filter ([Termination Date] Is Null) and created the first 'apply filter' command button (using the wizard), then cleared the filter, applied the second filter ([Termination Date] Is Not Null), and created the second command button. It changed the first button to apply the same filter as the second button.
How do I create two different filter options on the same form? Using the wizard, the event procedure that was created is:
Private Sub CmdCurrent_Click()
On Error GoTo Err_CmdCurrent_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
Exit_CmdCurrent_Click:
Exit Sub
Err_CmdCurrent_Click:
MsgBox Err.Description
Resume Exit_CmdCurrent_Click
End Sub
I don't understand enough of this to know how to change it.
Any ideas?
Angi
Hi Angi,
First of all, don't worry about not understanding the DoCmd.DoMenuItem command. Nobody understands that unless they have all 5 previous versions of Access installed and running and they go to the menu bars and count the steps!
What I think you need is an option group with two toggle buttons (the ones where when one is pressed, the other pops up)
In the option group's AfterUpdate event you need something like (I'm just typing here, the code hasn't been checked) - Private Sub ToggleOne_OnClick()
-
-
If Me.ToggleOne = True Then
-
Me.Filter = "[Termination Date] Is Null"
-
Me.FilterOn = True
-
Else
-
Me.Filter = "[Termination Date] Is Not Null"
-
Me.FilterOn = True
-
End If
-
-
End Sub
The actual filter wording may need some work, I seem to remember that it should be like an SQL WHERE clause without the word "Where"
Good Luck
Jim
Ps if you need a third option (all employees) you'll need a third option button, ElseIf testing (or possibly a Select Case statement) and Me.Filter = ""
Thanks, Jim. I got it to work. For the record, here's what it looks like. (Case 2 is current, 3 is former, and 1 is all.)
Private Sub Frame107_AfterUpdate()
Select Case Frame107
Case 2
Me.Filter = "[Termination Date] Is Null"
Me.FilterOn = True
Case 3
Me.Filter = "[Termination Date] Is Not Null"
Me.FilterOn = True
Case 1
Me.FilterOn = False
End Select
End Sub
Angi
Thanks, Jim. I got it to work. For the record, here's what it looks like. (Case 2 is current, 3 is former, and 1 is all.)
Private Sub Frame107_AfterUpdate()
Select Case Frame107
Case 2
Me.Filter = "[Termination Date] Is Null"
Me.FilterOn = True
Case 3
Me.Filter = "[Termination Date] Is Not Null"
Me.FilterOn = True
Case 1
Me.FilterOn = False
End Select
End Sub
Angi
Good work.
Jim
Edited to add more characters (stupid 20 character limit)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jeffgeorge |
last post by:
Hi all. Trying to move Filter By Selection, Filter By Form, and
Apply/Remove Filter directly into my form. No luck. Is there anyway
to move them into the header of the form or, as another...
|
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: lorirobn |
last post by:
Hi,
I have a report that works just fine.
Now I would like to add the capability to choose selection criteria to
limit what is displayed. I created several reports that do this, but
they used...
|
by: chiinook |
last post by:
I have been creating a contact management database which now has about
300 records in it. I've been filtering using the "filter by form"
command but I'd like to automate this with a set of buttons...
|
by: mattscho |
last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form.
--------------------------------------------------------------------------------
Hi All, Trying to create a set of 3 buttons in...
|
by: AccessNewbie |
last post by:
Hello:
I have a form (frmMain) that I have included a subform (frmSubForm)
on. What I need on the MAIN form are command buttons that will filter
the information on the SUBFORM. It is very...
|
by: eHaak |
last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
|
by: aas4mis |
last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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...
|
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...
| |