473,811 Members | 3,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search Menu - How to use multiselection with check boxes

24 New Member
Hello,

I am quite begginer in MS Access and I have a problem with forming search menu. I used help from http://allenbrowne.com/ser-62.html but I have still some problems.
I have check boxes for Products: GT, ST, Nuclear, Generator. Then I have in the Detail part of the SearchNews form the answers that will be showned after selection of Products. I want to have possibility to select from 1 to 4 product at once. But when I used the code from the site above, I can only use one, cause if i tag GT and ST it takes only records with those 2 product at the same time.

I want to have the records with only GT OR only ST OR with both. I saw some codes for that, but that was a lot of combination for that, and I have also other check boxes with 22 possibility to choose... so in that case this way is too long. Is there short code, macro or other way to use search possibilities for multiple check box selection?

I hope that I decribed the code clearly. I would be greatful for any clues.

Greets

Greg
Nov 14 '07 #1
5 1945
Lysander
344 Recognized Expert Contributor
Hello,

I am quite begginer in MS Access and I have a problem with forming search menu. I used help from http://allenbrowne.com/ser-62.html but I have still some problems.
I have check boxes for Products: GT, ST, Nuclear, Generator. Then I have in the Detail part of the SearchNews form the answers that will be showned after selection of Products. I want to have possibility to select from 1 to 4 product at once. But when I used the code from the site above, I can only use one, cause if i tag GT and ST it takes only records with those 2 product at the same time.

I want to have the records with only GT OR only ST OR with both. I saw some codes for that, but that was a lot of combination for that, and I have also other check boxes with 22 possibility to choose... so in that case this way is too long. Is there short code, macro or other way to use search possibilities for multiple check box selection?

I hope that I decribed the code clearly. I would be greatful for any clues.

Greets

Greg
Hi Greg,

Looking at the link, the code there specifically states it will only return records where all criteria match.
Expand|Select|Wrap|Line Numbers
  1.     'Notes:     1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
  2.                     we remove the trailing " AND " at the end.
  3.  
What you need to do is replace the AND with OR and that should produce the result you want
Nov 14 '07 #2
dillneus
24 New Member
Hi Greg,

Looking at the link, the code there specifically states it will only return records where all criteria match.
Expand|Select|Wrap|Line Numbers
  1.     'Notes:     1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
  2.                     we remove the trailing " AND " at the end.
  3.  
What you need to do is replace the AND with OR and that should produce the result you want
Ok, thx for answer.
Actually I found out that its working with AND but only if in that case:

I have product: GT, ST, nuclear.
if i choose GT - give me GT (OK). If i choose GT, ST give me GT ST (OK)
but then if i change again to GT, i have only GT but in the same time ST are excluded (Not OK, i want to see also records that are ST and GT).
So in that case i dont see the records of both ST and GT. how to change that...
I dont want to have ST false if i check it out. i hope you know what i mean...
where should i change that option ...
Nov 14 '07 #3
Lysander
344 Recognized Expert Contributor
Ok, thx for answer.
Actually I found out that its working with AND but only if in that case:

I have product: GT, ST, nuclear.
if i choose GT - give me GT (OK). If i choose GT, ST give me GT ST (OK)
but then if i change again to GT, i have only GT but in the same time ST are excluded (Not OK, i want to see also records that are ST and GT).
So in that case i dont see the records of both ST and GT. how to change that...
I dont want to have ST false if i check it out. i hope you know what i mean...
where should i change that option ...
Ok, I need to see what you are running. Could you please post the actual code you are using to make the selections?
Nov 15 '07 #4
dillneus
24 New Member
Ok, I need to see what you are running. Could you please post the actual code you are using to make the selections?
Hey
I didnt changed the code a lot and i left AND but i removed "False" part of every code...and now its working ok. although its not perfect, but at least working :) the only problem is if i choose GT and ST it takes me common value, but i revised it and it could be like that. Thanks for help.

Btw this is the code I used for check boxes:

Private Sub FilterProduct_C lick()
'Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form's Filter.
'Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).
Dim strWhere As String 'The criteria string.
Dim lngLen As Long 'Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates in a JET query string.

'************** *************** *************** *************** ************
'Look at each search box, and build up the criteria string from the non-blank ones.
'************** *************** *************** *************** ************


'Yes/No field and combo example. If combo is blank or contains "ALL", we do nothing.
If Me.GT = -1 Then
strWhere = strWhere & "([GT] = True) AND "
End If
If Me.ST = -1 Then
strWhere = strWhere & "([ST] = True) AND "

End If
If Me.Nuclear = -1 Then
strWhere = strWhere & "([Nuclear] = True) AND "
End If

If Me.Generator = -1 Then
strWhere = strWhere & "([Generator] = True) AND "
End If

If Me.Coal = -1 Then
strWhere = strWhere & "([Coal] = True) AND "

End If
If Me.Wind = -1 Then
strWhere = strWhere & "([Wind] = True) AND "
End If
If Me.Solar = -1 Then
strWhere = strWhere & "([Solar] = True) AND "
End If

If Me.Geothermal = -1 Then
strWhere = strWhere & "([Geothermal] = True) AND "

End If
If Me.Other = -1 Then
strWhere = strWhere & "([Other] = True) AND "
End If

If Me.GasOil = -1 Then
strWhere = strWhere & "([GasOil] = True) AND "

End If


'************** *************** *************** *************** ************
'Chop off the trailing " AND ", and use the string as the form's Filter.
'************** *************** *************** *************** ************
'See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere

'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If

End Sub
Nov 16 '07 #5
Lysander
344 Recognized Expert Contributor
From what I can see, changing the AND to OR will give you the result you want. i.e.
Change

If Me.GT = -1 Then
strWhere = strWhere & "([GT] = True) AND "
End If

To

If Me.GT = -1 Then
strWhere = strWhere & "([GT] = True) OR "
End If

and all the rest.

At the end, where it set lngLen to strWhere-5, this needs changing to -4

Hopefully this will work
Nov 16 '07 #6

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

Similar topics

2
3283
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help with this problem. I am uncertain about what etiquette calls for, but more on that later. My Objective: I am trying to control the _VMWare Desktop_ application
2
2405
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is to search by one ingredient, sometimes by two, and sometimes by three. There won't always be a second and third ingredient to search on. It will depend on how the user wants to search. The database set up with multiple tables mainly one for all the details related to the recipe and...
5
5181
by: Steven | last post by:
I have some text boxes on a form in MS Access 2000. When I right click in them I don't get any shortcut menu at all. I want the normal cut, copy, and past menu to come up. In the "Startup", I have the "Shortcut Menu Bar:" set to (default) The "Shortcut Menu Bar" property of the text boxes, is empty. So, where is my cut, copy, and past????? Thanks....
2
7253
by: Homey! | last post by:
Hello all I am new to Access. I have imported data from an old FoxPro 2.x database. This is probably the most basic function but I cant get a search box to work. I need to search for company name and cant figure it out in access. Tony (homey)
1
2074
by: DJG79 | last post by:
Hi all, I am using an open source menu that i found and it works great, except for one thing that when the web page is not scrolled to the very top the drop down links will not stay visible. Has anyone else had this sort of problem with javascript? and any ideas how to fix it would be greatly appreciated.. I have included a copy of the code below, thanks. /**
3
3314
by: mahesh123 | last post by:
Hi, I want to select the records in multiselection randomly in the MSFlexGrid? In MSFlexGrid there is multiselection option by press the Shift key and select the records, but there we can selecting the records sequentially. I want to select the multiple records in randomly. Its very urgent for me. Please help as soon as possible. Thanks ---------- Mahesh
7
1436
by: Mel | last post by:
What control do I use for a menu on a web page? How do I add a check box to an menu item? I have a menu called Chart and beneath it I have a menu item called Publish. I want to display a checked check box when Publish is selected and an unchecked box when it's selected again. Can anyone point me in the right direction? (using asp.net 2.0, vb.net 2005)
2
2756
by: woodey2002 | last post by:
Hi Guys and thanks for your time. I have a search form for my database that allows users to select multiple criteria from multi select list boxes. I successfully integrated a multi select listbox for users to select and search for counties. On the same page however I would like to integrate a similar multiselect box for nationality. I would like the user to be able to search for nationality with county or individually. After...
6
4682
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option for 2 list boxes:- county and nationality, while trying to add a third multi select list box for qualifications search is where i encounter my problem. I've copied the working code from my working list boxes, however it cant seem to pick up the...
0
9731
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10393
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.