And Or in a Parameter Query

How do you make use of AND or OR in a Parameter Query?  Entering one value 
works fine, but using and/or retrieves an empty string.  Any ideas?
0
Utf
12/17/2009 12:14:01 AM
access.queries 6343 articles. 1 followers. Follow

4 Replies
718 Views

Similar Articles

[PageSpeed] 30

A parameter query uses and /or just like any other query as far as I 
know.  You can't use and / or in the parameter section because you can't 
have more then one data type assigned to a field.  That is the point 
behind a parameter query:  Acccess is unable to determine what type of 
data is being stored/returned, Currency, Date, whatever, so you use the 
parameter to force it to work with that data one consistent way.

However, just because it is a parameter query, does not mean you can not 
use and/or in the criteria like you would any other query.

Phil




On 12/16/2009 4:14 PM, NEWER USER wrote:
> How do you make use of AND or OR in a Parameter Query?  Entering one value
> works fine, but using and/or retrieves an empty string.  Any ideas?

0
Phil
12/17/2009 12:30:19 AM
OR: enter each criteria on a separate criteria line
AND: enter all criteria on one criteria line

You will often have combinations, such as this:

Looking up data where the quantity is >= 15 and <= 25 and the CustomerName 
is "JONES" or "SMITH". In this case, JONES goes on one line in the 
CustomerName criteria field, SMITH on the one below. The >= 15 AND <= 25 goes 
on EACH line of the Quantity criteria field.

"NEWER USER" wrote:

> How do you make use of AND or OR in a Parameter Query?  Entering one value 
> works fine, but using and/or retrieves an empty string.  Any ideas?
0
Utf
12/17/2009 3:14:01 AM
When the parameter box comes up for you to enter the value, are you typing 
your values and 'and/or' in the box i.e. say you wanted 'Fred' or 'Joe' are 
you typing Fred or Joe in the parameter box?

If so, you need to put two parameters in your query criteria, i.e. 
[Parameter 1] or [Parameter 2], then you will get two boxes, type Fred in the 
first and Joe in the second and it will work.

Let us know if any of the answers help you.....



"NEWER USER" wrote:

> How do you make use of AND or OR in a Parameter Query?  Entering one value 
> works fine, but using and/or retrieves an empty string.  Any ideas?
0
Utf
12/17/2009 11:19:01 AM
As you can see, there is a little bit of confusion on whether you meant
"I want to enter Joe or Bob as a response to the parameter and have it find 
records with Joe or Bob."  Or whether you meant " I want to enter Joe in one 
parameter prompt and Bob in a second parameter prompt and have records 
returned with Joe or Bob."

Parameter prompts contain ONE value.  So if you enter "Joe Or Bob" in a 
parameter, the search will be for that string and there is probably no record 
with "Joe Or Bob" as a value in one field.  Parameter prompts cannot contain 
conjunctions (and/or) or comparison operators (=,<,>) or arithmetic 
expressions.  They can contain strings with those items but they are just 
characters in the string and have no effect on what happens in the query.

The best solution in this case is probably to build the query string (or at 
least the filter - where clause) using VBA and a form to get the value or values.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Emma Hope wrote:
> When the parameter box comes up for you to enter the value, are you typing 
> your values and 'and/or' in the box i.e. say you wanted 'Fred' or 'Joe' are 
> you typing Fred or Joe in the parameter box?
> 
> If so, you need to put two parameters in your query criteria, i.e. 
> [Parameter 1] or [Parameter 2], then you will get two boxes, type Fred in the 
> first and Joe in the second and it will work.
> 
> Let us know if any of the answers help you.....
> 
> 
> 
> "NEWER USER" wrote:
> 
>> How do you make use of AND or OR in a Parameter Query?  Entering one value 
>> works fine, but using and/or retrieves an empty string.  Any ideas?
0
John
12/17/2009 12:42:40 PM
Reply:

Similar Artilces:

Append Query 02-28-08
I am trying to append data from tblitemline to tblitemlist. I only want to append new records. The unique field is ListID. I want to append 4 fields total. I can't get it to limit it to new records. Any help would be appreciated. Thanks! New on the basis of what criteria.? Whatever that criteria is it should either the primary key (there can be multiples fields involved as the primary key) or Indexed with NO duplicates, (this will work if the criteria is a single field). Once you set the table up that way, the append query will only add "new" records. You can still have a ...

database query/names issue, causing excel to be sluggish
I have an issue with an excel worksheet I've created. WorkbookA has "Names" which are used to define drop-down menus in WorksheetA. These "Names" are defined to reference a WorksheetB (also in WorkbookA) which itself is populated by a database query, pulling from another Excel WorkbookB. The logic is that WorkbookB should not be touched by the User, only an Admin, and Workbook A is used by User. The Names in WorkbookA are to prevent incorrect entries. Now that I've set it up, WorkbookA is moving really sluggish, but if I delete all the Names it speeds up again....

which query is faster, better to use?
There are multiple AdjournmentDates for any given NoticeID in tblNotices_AdjournemntDates. I want the most recent date for each NoticeID. Both of these produce the correct results. Is either one better than the other? SELECT DISTINCT NoticeID, (SELECT TOP 1 AdjournmentDate FROM dbo.tblNotices_AdjournmentDates WHERE NoticeID = A.NoticeID ORDER BY AdjournmentDate DESC) FROM dbo.tblNotices_AdjournmentDates A SELECT NoticeID, AdjournmentDate FROM dbo.tblNotices_AdjournmentDates A WHERE (AdjournmentDate IN (SELECT TOP 1 AdjournmentDate FROM tblNotices_AdjournmentDates WHER...

Load query with outdata until search
I have a form with sub form on it I use this form to search for products we keep in stock with prices, I have a Search text box on the form then i type in the product then hit the search button and it requerys the sub form Only problem i have is when i first load the form it show every product in the subform, so takes a long time to load Is there a way to load the page with out the date then i can type in product i want to search for then it displays the products Simon What about setting the .RecordSource property of that form (?subform) to "" in the OnLoad event,...

query problem 02-11-08
Hi to Everyone I have a table (tblMunka) with the following columns: JobId; PersonalId;AreaId;StartDate;EndDate;ActiveJob I would like to a query which tell me how many personal was in a term in an area. I have a form (frmLetszam) where user can choose start and end dates from a calendar. I've tried with this but the result is not good: HAVING (((tblMunka.StartDate) Between [Forms]![frmLetszam]![cboEndDate] And [Forms]![frmLetszam]![cboEndDate])) OR (((tblMunka.StartDate)<[Forms]! [frmLetszam]![cboStartDate]) AND ((tblMunka.EndDate) Is Not Null)); Please help me! Best regards -- Mes...

SetSockOpt with SO_REUSEADDR parameter
Hi, I write a server application to send message to multiple clients connected to it. So I create multiple UDP sockets with the same port to send data. At first, I get the error code " 10048 " and find a solution from MSDN. It tells me to use SetSockOpt with SO_REUSEADDR. I rewrite the function that creates a UDP socket: ======================================= // CUdpSendSocket is derived from CAsyncSocket void CUdpSendSocket::CreateSocket(UINT nPort) { TCHAR szError[256]; BOOL bRet = Create(nPort, SOCK_DGRAM, FD_WRITE); if (bRet != TRUE) { wsprintf(szError, ...

Query with Combo Boxes on a Form
I'm using QBF with about six different combo boxes using: [forms]! [formmain]! [combo1] or [forms]![formmain1]![combo1] -like in a VBA book. This is so users can select criteria on a form with the combo boxes, and when they are done, they hit the search button, and it opens up another form based on the query just performed by the combo selection. This worked for about three combo boxes, but when I added another one, it freezes up and opens up a blank page. It's supposed to open the new form based on the query. Is there a better way to do this? Any help would...

LDAP Query #4
im sorry if this post is in the wrong group how can i create an ldap query to get all the users with exchange boxes inside a specific OU this OU might also have OUs indise it with users that hafve mailboxes i want this to be able to create customized address lists Thank you Address Lists cannot be targeted at particular OUs. You need to use some user attribute that's common for users in that OU - like department, location, company name, etc. -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog ----------------------------------------- "Nazgyl" <naz...

Creating a Report using two queries
I have created a chart report (bar chart) using one query. How can I create another single chart showing the results of both queries. One will show the bars of first query data and the other will show bars of the data from second query together in a single chart report. Any suggestions? -- FL This depends on how/if the two queries are related. I would expect the "X" axis values might be related. If so, join the two queries into a single query and graph the new query. -- Duane Hookom Microsoft Access MVP If I have helped you, please help me by donating to UCP http://www...

Complex Update Query in SQl Server 2000
I need to update ACTINDX in UPR40500 for each JOBTITLE in MYTABLE. We have modified the ACTNUMBR in 'MYTABLE' whose segments are contained in GL00100 GL00100 ACTINDX ACTNUMBR_1 ACTNUMBR_2 ACTNUMBR_3 ACTNUMBR_4 ACTNUMBR_5 30562 222 411001 000000 150 350 30563 222 411001 000000 155 355 UPR40500 JOBTITLE ACTINDX 209401 30562 150001 30563 MYTABLE JOBTITLE ACTNUMBR 209401 222-411001-000000-150-350 150001 222-411001-000000-155-355 Sean: If you are storing the account number as a string in my table, an...

Select Query Broken
Does any one know, of the issue in A2k3 With the Query, I was creating some combo list filters, via query's then putting the SQL in a Marco Apply filter. work great then all i sudden, now, when i view the query in normal mode, (NOT Design mode) Its Showing all the fields that are related on the table the query is based on, even though only two fields have been selected. and the show tick is ticked? just for 2, any ideas whats happening here? ive tried repairing and compacting database and also restarting access no luck? On 10 Sep, 16:42, KARL DEWEY <KARLDE...@discussions.microsoft...

Public folders: query regarding the "synchronize now" function
Exchange 2003 SP2 I have a query regarding the "synchronize now" function for public folders. Say I have a public folder called "Bob" with replicas on 3 servers (ServerA, ServerB, ServerC) If I drill down to Folders/Public Folders Select the "BOB" public folder and select the "Status Tab" on say ServerA, I see all 3 replicas listed as expected: If I right click a replica I can select "synchronize now" what does this do exactly? Does it: 1) Push updates out from the replica where you right click and select "synchronize now" ...

Query Button Problem
On my form, I need to put a button to run a query. When using the toolbox in the Design View, I use the Command Button Toolbar, then use MIscellaneous, then Run Query. I select the correct one, and save it to the form. When I try to use it, I get an error message, and it will not work. What is going wrong? Can't figure it out if you don't provide an error message. On Fri, 1 Feb 2008 10:52:00 -0800, Shari <Shari@discussions.microsoft.com> wrote: >On my form, I need to put a button to run a query. When using the toolbox in >the Design View, I use the Command Button To...

criteria for filtering check boxes in a query
I am trying to do a permanent sort for columns using check boxes. I need to know the formula for the criteria box On Wed, 20 Jun 2007 14:54:41 -0700, Desiree wrote: > I am trying to do a permanent sort for columns using check boxes. I need to > know the formula for the criteria box What is "a permanent sort for columns using check boxes". Perhaps your terminology is clear to you, but I think you would do well to re-think and repost your question. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail On Thu, 21 Jun 2007 15:38:03 -0700, Desir...

adding fields in query
I am trying to add fields in a query to put into a new field. For example; FieldOne, FieldTwo, and FieldThree should equal FieldFour. FieldOne has a value of 1, FieldTwo has a value of 2 and FieldThree has a value of 3. When I try =FieldOne+FieldTwo+FieldThree in FieldFour with the expression builder, it does not add them, it just shoves all their values together. Instead of FieldFour having a value of 6 when I run the query, it gives me a value of 123. I have also tried the "&" instead of "+", and I get the same results. I have tried changing the To...

stop returning column headings from DB query
I put together a query to go against Oracle that returns a block of data to the spreadsheet. Is there an option somewhere to have the "Return Data to Excel" do so without also returning the column headings? I want the data only. thanks - Russ There are 2 places that you can change that setting..... 1)When you return data from MS Query the dialog where you select the location for the data has a Properties button. Click that button UNcheck: Include Field Names.......click [OK] Continue selecting the query destination OR 2)After the data has been pulled from Oracle Right-click...

Tranform Pivot Query?
I hv 2 tables with structure as below: [Empl] ID Name 1 Mr A 2 Mr B 3 Mr C 4 Mr D 5 Mr E [Empl_Tran] TrID Empl_ID Date Code 1 1 10/11/2009 SL 2 1 10/11/2009 TR 3 1 11/11/2009 W 4 1 12/11/2009 W 5 1 12/11/2009 TR 6 2 10/11/2009 SL 7 2 10/11/2009 TR 8 2 11/11/2009 W 9 2 12/11/2009 W 10 2 12/11/2009 TR 11 3 10/11/2009 SL 12 3 10/11...

Web query again
Hello, I looked on MSDN about web queries with VBA. But the code I took from there doesn't work. Dim BaseURL As String BaseURL = "some URL" Const StartDate As Date = #11/2/2004#, EndDate As Date = #4/20/2005# Dim d As Date For d = StartDate To EndDate Dim newSheet As New Excel.Worksheet Set newSheet = Worksheets.Add With newSheet .Name = Replace(CStr(d), "/", ".") Call .Activate End With 'MsgBox ("URL;" & BaseURL) 'Next line gives an error 'Run-time error '5': 'Invalid ...

emailing query window type result messages
I'm creating some backup procedures. While testing them in the query window, I'll get messages like this: 100 percent processed. Processed 0 pages for database 'Caser', file 'Caser_Log' on file 1. BACKUP LOG successfully processed 0 pages in 0.097 seconds (0.000 MB/sec). The backup set on file 1 is valid. I knonw how to do this: BACKUP LOG [Caser] TO DISK = @BackupLocationAndName WITH NOFORMAT, NOINIT, NAME = @BackupName, SKIP, REWIND, NOUNLOAD, STATS = 10 SET @Err = @@ERROR IF @Err <> 0 BEGIN EXECUTE msdb.dbo.sp_notify_operator @name = ...

data base query
I have a workbook with 2 work sheets. Eacch contains data from a database query( 2 different databases) Is it possible to create a pivot table from the 2 sheets ? ...

Exporting a Query to Excel
Hi, I have a query of Purchase Oders, sorted by month, for a particular business unit and was wondering if there was a way to export the data to one excel workbook, but to have 12 tabs of monthly data instead of having to separate it out manually. thanks -- C. Williamson Here is some code that I wrote for a poster a few months ago that will do this type of export. You'll need to modify the code so that it will loop through a list of months instead of a list of managers. Post back with questions (and with more details) if you have problems. Generic code to create a temporary qu...

SQL Server 2005: SELECT INTO & pass-through query
Hi I often use pass-throgh queries to get data from external sources - something like following example: ---------------------------------------------- Use MyDaytabase -- Declaring variables DECLARE @SQLString varchar(max) DECLARE @OpenQuery varchar(max) DECLARE @LinkedServer varchar(max) -- Declaring table variables DECLARE @Q1 TABLE( id INTEGER, Field1 DATETIME, Field2 VARCHAR(50), Field3 INTEGER) -- Setting variables SET @LinkedServer = 'MyLinkedServer' SET @OpenQuery = 'SELECT * FROM OPENQUERY(' + @LinkedServer +',''' -- Co...

MS "Query", MS Excel not playing nicely
Using Excel 2000 (9.0.2720), Clicking Data, Get External Data, New Database Query. Not working. Says, "Waiting for data to be returned from Microsoft Query" in the status bar, then pops up a dialog that says, "Microsoft Query could not be started because it isn't installed. You can install Query by running the installation programyou used to install Office or Excel. The Query option is in the Office Tools category." But I *DID* install Query!!! If I set MS Query (in Control Panel, Add/Remove Programs, MS Office) to "install on 1st use", then Excel knows it n...

Access97 Queries connecting via ODBC to Sybase SQLanywhere backend
I have a Access97 frontend database and it links tables and queries to a Sybase SQLAnywhere backend database. I have imported all the tables from the SQLAnywhere into a Access97 database. I have changed the linked relationship in the tables section to point to the Access97 backend now and not the Sybase backend. Problem is I have SQL queries written in the Access 97 frontend that still try to access Sybase via ODBC. How do I change these queries to access the new Backend. Jamie Network Administrator If the queries were originally written using linked tables, they should still work. Ho...

Querys based on Querys
I have querys based on querys in access, for example when I click a button final query runs which is based on A Query , and because A query is based on a B query and so on, I can get desired results in the final query (for example in a report or form) My question is, can this be done in code builder ? how to reference all those queries at run time , like for example first the A query needs to be resolved and then B query and C query and then finally the result is displayed in the final query, Thanks the query or queries that the final query is based on, will run automatically regardless...