473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

access checkbox filter

greeting all,

I am building a form for my company to filter out some sales figures
for different months. anyway, here is my idea

i have 12 checkboxes represeting each months.
users will select any checkboxes they want to view the sales figures
for that month
they can choose more than 1 month

for example if they choose checkboxes 1,5,7; that means they will be
shown the sales figures for month 1,5,7

is there any way to do some things?

thanks very much in advanced.

Nov 13 '05 #1
5 7080
The idea will be to build up a string to use in the Filter of your form.

This example assumes check boxes named chk1, chk2, ...chk12, and a date/time
field to filter on named SalesDate:

Dim i As Integer
Dim lngLen As Long
Dim strWhere As String

For i = 1 to 12
If Me("chk" & i).Value Then
strWhere = strWhere & i & ","
End If
Next

lngLen = Len(strWhere) - 1 'Without trailing comma
If lngLen > 0 Then
strWhere = "Month([SalesDate]) IN (" & Left$(strWhere, lngLen) & ")"
Me.Filter = strWhere
Me.FilterOn = True
Else
Me.FilerOn = False
End If

--
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.

"Neji" <ji********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
greeting all,

I am building a form for my company to filter out some sales figures
for different months. anyway, here is my idea

i have 12 checkboxes represeting each months.
users will select any checkboxes they want to view the sales figures
for that month
they can choose more than 1 month

for example if they choose checkboxes 1,5,7; that means they will be
shown the sales figures for month 1,5,7

is there any way to do some things?

thanks very much in advanced.

Nov 13 '05 #2
Thanks Allen for your code.

I tried the code, but "Invalid use of Me Keyword"

did i miss anything?

thanks for your advice.

Nov 13 '05 #3
The code is designed to go into the module of the form. For example, you
might have a command button on your form to apply the filter after checking
the boxes. Set the button's On Click property to:
[Event Procedure]
Click the Build button (...) beside that.
Put the code into the event procedure between the "Private Sub..." and "End
Sub" lines.

--
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.

"Neji" <ji********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Thanks Allen for your code.

I tried the code, but "Invalid use of Me Keyword"

did i miss anything?

thanks for your advice.

Nov 13 '05 #4
Thanks very mcuh.

in the code, do i need to specific which table i am referring?

or do i need to create any query as well ?

i am still very new to acces, esp to these form making.
thanks a lot for your time.

Nov 13 '05 #5
Yes. The code was just an example, and you will need to understand it and
adjust it so that it matches the name of your items.

--
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.

"Neji" <ji********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Thanks very mcuh.

in the code, do i need to specific which table i am referring?

or do i need to create any query as well ?

i am still very new to acces, esp to these form making.
thanks a lot for your time.

Nov 13 '05 #6

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

Similar topics

3
by: TrvlOrm | last post by:
I am having great difficulty in these asp scripts, using VBscript and JavaScript. I have 4 files that all need to be linked together. The first file "Books.html" - needs to search for a Book...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
6
by: Megan | last post by:
Hi everybody- I'm trying to use a checkbox to control whether or not a date field in a query "Is Null" or "Is Not Null." I have 2 date fields: InDate and OutDate. If there is an OutDate, then...
1
by: Paul | last post by:
I could really use some help please. SETUP: I have a table called "ProductTable" I have a query called "ProductQuery" based on ProductTable I have a form Called "ProductMF" based on...
6
by: rad | last post by:
I am stuck with this problem. I need to create form with checkbox that must be populated dynamically from a table. For example, if I have a table called Fruits, and the values are "Apple",...
2
by: John Smith | last post by:
How can I use a transparent command button to change a checkbox? I have my records set up in a continuous form and I want theuser to be able to click on the record and have this toggle the...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing an .RLDC report in local report. The columns for the report are essentially: Month Item #1 Item#2 Item#3 ...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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
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,...
0
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...

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.