Access Query To Accept Multiple Check Box Parameters
Nov 9, 2007
Hi,
I really hope someone will be able to help me with this one as I am sure im just missing something simple.
I have an unbound form which has 20 yes/no unbound check boxes. The purpose of the form is to allow users to tick the various fields and a subform return the results. The subform, which does requery when a check box is ticked is based off a query. Initially, I wanted all the records to display before any check boxes are ticked so I have used the following criteria:
Like IIf([Forms]![Search]![Field1]=False,"*",[Forms]![Search]![Field1])
Which basically reads if field1 is no then display all records, else display all yes. Now that works fine but what I would like to have working is that if a client ticks field1, field2, and field3 it displays all records that have ‘yes’ in either field. Currently, if more than field is ticked the query treats it like:
Field1 And Field2 And Field3 And etc = true
I want to be able to select several check boxes and have the query return results for each check box that was checked. I would like to avoid doing this by having an append and delete query per checkbox.
Thank you
View Replies
ADVERTISEMENT
Mar 27, 2014
How to modify my query to accept parameters from a multiple choice list box. This is the SQL code behind my search query:
SELECT AircraftOperators.RegistrationNumber, AircraftOperators.PassengersNumber,
AircraftOperators.ManufactureYear, AircraftOperators.EmailToOperator, AircraftOperators.ExteriorPhoto,
AircraftOperators.InteriorPhoto, tblListOfAircraftOperators.OpratorName, tblAircrafts.AircraftType, tblAirports.AirportName, InfoSource.SourceType, tblCountry.CountryName, tblAircraftCategory.AircraftCategory
[Code] ....
I have got an unbound multiple list box called List44 (Row Source: query based on table tblAircraftCategory, Multi Select - Extended) that needs to be passing parameters to my main query called AircraftSearch2. The multiple choice list box have the following fields:
1. Piston
2. Turbo Prop
3. Entry Level Jet
4. Light Jet
5. Super Light Jet
6. Midsize Jet
7. Super Midsize Jet
8. Heavy Jet
9. Ultra Long Range
10. Helicopter
11. Air Ambulance
12. Cargo
13. Vip Airliner
14. Airliner
The user will use the form for selecting search criteria (the form is called SearchForm2 and has 5 combo boxes, 3 text boxes and one multiple choice list box).
I'm very new to access and need to modify (or coding a separate module) my query to include my multiple choice list box in my query?
View 4 Replies
View Related
Jan 4, 2006
I have this code of a command button, which would allow me to generate the result of the SQL. I think the code is wrong... Can someone help? I guess something wrong with the bracket...
strSQL = " SELECT NewsClips.RecordNumber, NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips " & _
"WHERE (NewsClips.[NewsSource] " & strNewsSource & _
strNewsSourceCondition & "NewsClips.[1CategoryMain] " & str1MainCate & ")" _
str2MainCateCondition & "(" "NewsClips.[NewsSource]" & strNewsSource & _
strNewsSourceCOndition & "NewsClips.[2CategoryMain] " & str2MainCate & ")" ";"
Indeed, I try to modify the SQL that works in a test query (as I want to know what went wrong with my code): the changes would be replace OR to a toggle option.
SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment
FROM NewsClips
WHERE (((NewsClips.NewsSource)=[Which News Source]) OR ((NewsClips.[1CategoryMain])=[Which Category?])) OR (((NewsClips.NewsSource)=[Which News Source]) OR ((NewsClips.[2CategoryMain])=[Which Category?]))
ORDER BY NewsClips.IssueDate DESC;
Your help will be greatly appericated.
View 3 Replies
View Related
Oct 31, 2005
I am trying to run the below union query, but it keeps asking for FRGHT_BL!FB_CREAT_DTM as a parameter. I want it to only ask for the Start Date and End Date once.
SELECT * FROM qLOC_ID WHERE(((FRGHT_BL!FB_CREAT_DTM) Between [Enter Start Date] And [Enter End Date])) UNION SELECT * FROM qLOC_ID2 WHERE(((FRGHT_BL!FB_CREAT_DTM) Between [Enter Start Date] And [Enter End Date])) UNION Select * From qLOC_ID3 WHERE(((FRGHT_BL!FB_CREAT_DTM) Between [Enter Start Date] And [Enter End Date]));
View 1 Replies
View Related
Nov 23, 2005
I have set up a parameter query in Access 2003 that asks the user for the "Section", such as "Admin", "Accounting" etc.
I need them to be able to respond to the prompt with more than one section if they want- sometimes just one, sometimes two or three or four.
So they can get "Accounting" and "Admin" both in the records that are returned.
The code:
SELECT T_ElainesMaster.Section, T_ElainesMaster.Login, T_ElainesMaster.Workstation, T_ElainesMaster.NT, T_ElainesMaster.Barcode, T_ElainesMaster.[PC model], T_ElainesMaster.[Emp Name], T_ElainesMaster.[swap or not], T_ElainesMaster.[Exp Date]
FROM T_ElainesMaster
WHERE (((T_ElainesMaster.Section) Like [What section would you like to include?]))
ORDER BY T_ElainesMaster.Section;
Thanks!
View 1 Replies
View Related
Mar 30, 2006
Hello
I have created a database for my department to log all of our jobs to keep track of them and I want to create a simple search for them but I am having difficulties.
I am familiar with creating queries to search tables for matching records, but is it possible to get search criteria from the user (ideally from a search form they fill in) to form the query?
For example, I would like the user to be able to query the jobs by month and/or business area and/or supplier...is this possible?:confused:
Any help gratefully received!!!
:)
View 2 Replies
View Related
Jul 3, 2013
I have a query thats outputs my costs on a project divided into 50 categories. Additionally, each project can be divided into 3 stages, each with the same 50 cost categories. I have been using a query that prompts the user which stage they would like to look at, and it works great.
However, it would be useful to be able to see all stages at once, next to one another.
So, essentially, i want to be able to input the stage parameter in the criteria box for three fields in the query, so instead of showing the costs for one stage at a time, it will show all three(and a summation across all stages), without a prompt.
It works when i set the one field manually to the first stage, but when i add additional fields, it returns a blank query.
View 1 Replies
View Related
Apr 30, 2014
I am trying to find a way to allow the user to enter multiple numbers in an unbound box that I will pass to a query as parameters. I already have it set up to pas the parameters from the form but if i try to do more than one number it doesn't work.
I have tried:
1306 or 1307 or 1308
1306, 1307, 1308
"1306 or 1307 or 1308"
I was reading somewhere that when the value is picked up from the form it is not like you are typing it right in the criteria box of the query.
So are there any other options here? Is there a way to enter all the number in a box and then use vba to create an array and then pass that to the query?
View 2 Replies
View Related
Jun 4, 2007
Hey folks,
Not sure if this is the best forum but decided to put it here anyway.
I have a Access query that reads:
SELECT bleh
FROM blah
WHERE something > 10
Then in Excel I pull the data across using:
Set qdf = db.QueryDefs(qryName)
Set rs = qdf.OpenRecordset
and paste the data using
ws1.Range("IV1").End(xlToLeft).Offset(0, 2).CopyFromRecordset rs
I now want to change the query so the where statement reads
WHERE something > [amt]
So the question is how do I pass the value for the parameter value for [amt] from excel to access?
View 1 Replies
View Related
Jun 9, 2013
I have a table field that contains a lot of part numbers in different format. One could be with hyphen while others are without hyphen.
record#1 : 4535-300-34567
Record#2: 453530034567
Record#3: 4535-301-56721
In this case record# 1 & 2 are same part number only difference is hyphen.
I want to set my query parameter [Enter part number] such a way, when some one enter 453530034567 it should pull both the record (record#1 & 2).
View 5 Replies
View Related
Feb 1, 2008
All,
I have a problem building a query using multiple check boxes. The situation is as follows:
I have a database to monitor enquiries which come into a central email account. I have devised a system where several check boxes are used to define the nature of the enquiry. Users can tick any number or none of the options to describe the enquiry.
I would like to create a query where users can search the database based on the check boxes which have been ticked. For example, if users want to search for enquiries where a specific three check boxes have been ticked, I would like all of the records where these three boxes are checked to appear, and so on for all different combinations of check boxes ticked.
I've tried a few methods, including creating a seperate form for the query where users check their search criteria in line with the enquiry form, but I can't link this with the original form.
I hope my description adequetly conveys the problem I have!
Any thoughts would be most welcome.
Rob
:confused:
View 2 Replies
View Related
Feb 12, 2014
i am very new to access and even vba. I have a form called FrmAgent. Here there are 5 check boxes [CheckBob] [CheckJim] [CheckNikita] [CheckNoe] [CheckKyle]. I have one button named "RecieveData". I have one table named "Agent" and a query called "QryAgent". in the same column there are five people Bob Jim Nikita Noe and kyle. What i need is to have the button when its clicked run my query to produce the data. However, if multiple boxs are checked i need the data for those people. As of right now if i click the button (doesnt matter how many boxs are checked) it gives me data for all five people. Is there a way i can do this where i can receive the data only for the people that their boxs are marked?
View 2 Replies
View Related
Feb 8, 2006
I have noticed diagrams showing Microsoft SQL Server accepting SQL statements sent by “SQL Requesters” over connections. I would like to know if Microsoft Access can be used in that fashion?
Put another way, can Access be configured to accept an SQL statement that another program (e.g. a VBA program in a VBA enabled 3rd party app) creates?
Currently, my VBA program instantiates an Access database object and then manipulates it (I just add a record to one of the tables), then closes and destroys it. This solution seems fragile (it stops working—I can explain more if needed). I would like to know if the technique inferred by my question would be more reliable.
View 2 Replies
View Related
Jun 27, 2006
I created the below query to come up with a new form. When I enter a single parameter, it works fine. When I modify the code and enter multiple patameters, it also works fine if I do not enter any information for the parameters. But once I enter one of the parameters information, then it does not come up with anything. I double checked and made sure it was typed in correctly. Is there a trick when entering multiple parameters on a query?
SELECT [JE 06 Log].[Operational Region Name], [JE 06 Log].[Period Name], [JE 06 Log].[Source System], [JE 06 Log].[Source Name], [JE 06 Log].[Category Name], [JE 06 Log].[Associated Category Name], [JE 06 Log].[JE Name], [JE 06 Log].[JE Base #], [JE 06 Log].Area, [JE 06 Log].[Line Description], [JE 06 Log].[Natural Account], [JE 06 Log].Description, [JE 06 Log].[JE Entry Date], [JE 06 Log].[Debit Amount], [JE 06 Log].[Credit Amount], [JE 06 Log].Amount
FROM [JE 06 Log]
WHERE ((([JE 06 Log].[Period Name])=[Enter Period]) AND (([JE 06 Log].[Source Name])=[Enter Path]) AND (([JE 06 Log].[JE Base #])=[Enter Base Number]) AND (([JE 06 Log].[Natural Account])=[Enter Natural Accnt])) OR ((([Enter Period]) Is Null) AND (([Enter Path]) Is Null) AND (([Enter Base Number]) Is Null) AND (([Enter Natural Accnt]) Is Null));
View 6 Replies
View Related
Feb 2, 2014
I'm creating my first web app with Access 2013 and I'd like to allow users to run a query after supplying a parameter to be used in the query.Simple example might be to display a list of all records that contain a date older than "x" in a particular field - with the user supplying the value for "x" I understand that query parameters don't work with the web browser and that I need to use a macro to request the input of "x" and pass it to the query, but I can't find any examples of this kind or macro action (OpenDialog, I understand from Jeff's book).
View 3 Replies
View Related
Nov 18, 2004
I have a table(Product Change) with these fields:
Tracking Number
Approved (a check box)
Engineering (text box that represents department)
Purchasing (text box that represents department)
Quality (text box that represents department)
Production (text box that represents department)
Customer Service (text box that represents department)
I want my query results to show all records that have the "Approved" check box...checked, and then only the records that have one of the Department fields with a null value.
So I'm looking to see only records that are "Approved" and out of those....only the records with at least one department field empty(Null).
Any help doing this is SQL view would be great...or even design view.
View 2 Replies
View Related
Jul 19, 2007
Hi everyone...
I'm a high school student working on an Access project for a summer internship. I needed your assistance in writing a criteria for a select query.
Table1 has the following fields:
ID, First_Name, Last_Name, Org, Email, Status
Only "Email" is mandatory, ID is autonumber, the rest are optional.
I have to create a query that will allow users to search the table with any of the fields above. A user may search with only one field, e.g. all users where "org" = "YMCA"
Presently, I am using the similar criteria for all the fields:
Like "*" & [Forms]![Search]![txt_FirstName] & "*"
The problem occurs when, for example a record exists with the following -
First_Name = Null or Blank
Last_Name = "Smith"
If you search for "Smith" in Last_Name, then the record does not show up, because First_Name in the record is blank.
How can I alter the criteria for it do search correctly?
I already tried:
Like "*" & [Forms]![Search]![txt_FirstName] & "*" & ""
Thanks,
Gautam
View 7 Replies
View Related
Jul 19, 2007
Hi everyone...
I'm a high school student working on an Access project for a summer internship. I needed your assistance in writing a criteria for a select query.
Table1 has the following fields:
ID, First_Name, Last_Name, Org, Email, Status
Only "Email" is mandatory, ID is autonumber, the rest are optional.
I have to create a query that will allow users to search the table with any of the fields above. A user may search with only one field, e.g. all users where "org" = "YMCA"
Presently, I am using the similar criteria for all the fields:
Like "*" & [Forms]![Search]![txt_FirstName] & "*"
The problem occurs when, for example a record exists with the following -
First_Name = Null or Blank
Last_Name = "Smith"
If you search for "Smith" in Last_Name, then the record does not show up, because First_Name in the record is blank.
How can I alter the criteria for it do search correctly?
I already tried:
Like "*" & [Forms]![Search]![txt_FirstName] & "*" & ""
Thanks,
Gautam
View 2 Replies
View Related
Nov 30, 2011
I am using Access 2003 and I am having trouble with a Combo Box on a form.
I had a combo box (based on a table), storing the choice in a field in the query and underlying table the form is based on. Everything was working fine, until... I altered the form based on a query. Now when you make a choice from the drop down list you get an error bell and nothing happens.
View 4 Replies
View Related
Aug 8, 2006
Can i create a query that will have a string in the Criteria box, where that string is assigned a value in VB code?
for instance:
Dim xyz As String
xyz = "TV"
and I put in the Criteria Box WHERE xyz = "Pizza"
View 4 Replies
View Related
Mar 23, 2005
Hello,
I've scoured the dozen archived threads that relate to my challenge, but I still can't quite overcome it.
I have an aggregate query that runs but returns no values.
This is how I've tried to set things up:
A user makes a multiple selection in a list box on a form.
The multiple selection gets strung into an SQL that I feed to a hidden control on the form.
Whatever is in the hidden control then becomes the Where clause that I reference in a Criteria cell in my query.
The query is run when the user presses a command button.
Can anybody tell what's wrong with my code? Thanks very much in advance!
Private Sub cmdTractSelect_Click()
On Error GoTo Err_cmdTractSelect_Click
'Declare variables
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim qry As QueryDef
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim strSQL As String
'Assign values to the variables
Set db = CurrentDb()
Set tbl = db.TableDefs("City")
Set fld = tbl.Fields("Tract")
Set qry = db.QueryDefs("Param")
Set frm = Forms!frmTractSelect
Set ctl = frm!lstTract
strSQL = "[Tract]="
'Grab the list-box selection and string it into SQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " Or [Tract]="
Next varItem
'Make sure the user selected at least one tract
If Len(strSQL) = 0 Then
MsgBox "You didn't select anything" _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
'Trim the SQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
'Insert the SQL into a hidden control that will feed_
'the criteria of the Tract field
txtWhere.Value = strSQL
'Run the query
DoCmd.OpenQuery ("Param")
Exit_cmdTractSelect_Click:
Exit Sub
Err_cmdTractSelect_Click:
MsgBox Err.Description
Resume Exit_cmdTractSelect_Click
End Sub
View 4 Replies
View Related
Apr 27, 2006
Hey Folks,
I have a form that has two things on it:
A button to open a query
A list box with names in it
How do I get the query so that it will select all records where the name field matches the chosen name from the list box?
View 2 Replies
View Related
Jul 26, 2005
I am trying to strengthen an already developed database at my work. They had a form with five different text boxes, each one that would run a seperate query on the same table, and the results would open on a different page. I am trying to combine all these text search parameters from the form to a single query and have the result come up on the form. I have done every search I can thing of from a forum search, a google search, and just reading through query forum posts for about a day; but I still cannot tell what is wrong. If someone could look at my code, and see if I have a mistake, or if I'm even in the right direction. :confused:
SELECT FLIGHTS.[FINISH OD], FLIGHTS.[PIPE OD/SHAFT OD], FLIGHTS.PITCH, FLIGHTS.[TYPE OF MATERIAL], FLIGHTS.[BURNED OD], FLIGHTS.[BURNED ID], FLIGHTS.[RIGHT/LEFT HAND], FLIGHTS.PartNumber, FLIGHTS.COMMENTS, FLIGHTS.[START TIME], FLIGHTS.[FINISH TIME], FLIGHTS.PurchaseOrderNumber, FLIGHTS.QTY
FROM FLIGHTS
WHERE ((FLIGHTS.[FINISH OD]=Forms![KNOWN BURN SIZES]!Text25 & "*") And (FLIGHTS.PITCH=Forms![KNOWN BURN SIZES]!text37 & "*") And (FLIGHTS.[TYPE OF MATERIAL]=Forms![KNOWN BURN SIZES]!Text32 & "*") And (FLIGHTS.PartNumber=Forms![KNOWN BURN SIZES]!Text0 & "*") And (FLIGHTS.PurchaseOrderNumber=Forms![KNOWN BURN SIZES]!text36 & "*"));
The FLIGHTS is the main table, [KNOWN BURN TABLES] is the form that the parameters are entered. I want users to be able to enter any fields they want and leave others blank. Currently all I get is a blank query. Sorry if the answer seems obvious; I tried avoiding posting till I knew that I couldn't figure it out on my own.
Thanks.
-Brian
View 8 Replies
View Related
Mar 30, 2005
I often use forms to select a parameter & date range for a subsequent report. Where I have chosen to use multiple combo boxes (two in this case)to select more than one parameter I have run into a problem. The report opens ok the first time but if I close it (report) and change my selection then the report refuses to open. Should I just requery the two combo boxes, is there something else or can't it be fixed?
View 1 Replies
View Related
Apr 22, 2008
I'm trying to setup a parameter that has a multiple choice so to speak. Rather then the user being able to enter whatever data they want.. I would like them to have a choice between two items.
Is it possible? if so.. how do I do it?
Thanks!
View 14 Replies
View Related
Mar 30, 2006
Hi folks,
I have a query that returns about 3500 records (and runs very well I have to say). the issue comes when I attempt to export that queries results to a comma seperated text file. It gives me the message that the field is too small to accept the amount of data..bla bla bla... I've looked this up and it mentions stuff about memo fields and issues with that, but I don't have any memo fields in any of the tables that this is pulling information from. Does anyone have a clue why this would be happening...please help..this is urgent.
Thanks - J
View 1 Replies
View Related