473,326 Members | 2,111 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,326 software developers and data experts.

Using both AND OR on the query

Good Day,

I'm trying to display record using a query below.
Expand|Select|Wrap|Line Numbers
  1. if sagent = "CARE" AND FDATE <>"" AND TDATE <>"" then
  2.  
  3. SQL = "SELECT * FROM WEB_PRODUCTIVITYDONE WHERE PROD_USER ='lckatigbak' OR PROD_USER ='jbmarquez' AND PROD_ENTERED BETWEEN #" & fdate & "# and #" & tdate & "#;"
  4.  
  5. end if
  6.  
What i'm trying to do is when i select CARE and enter FROM DATE and TO DATE is should display all the record that the user is under "lckatigbak" and jbmarquez" and between from date and to date.
Base on the query above it just display the all the record under those agent regardless of date.
The question is, It is possible to use OR AND at the same time on the query. is there any other way i could do it.

thank you in advance.
RJ Lorenzo
Oct 18 '08 #1
2 1326
JamieHowarth0
533 Expert 512MB
Hi there,

Firstly, please use [ code] and [/ code] tags around your code.

Second you could try using an IN clause:

Expand|Select|Wrap|Line Numbers
  1. if sagent = "CARE" AND FDATE <>"" AND TDATE <>"" then
  2.  
  3. SQL = "SELECT * FROM WEB_PRODUCTIVITYDONE WHERE PROD_USER IN ('lckatigbak','jbmarquez') AND PROD_ENTERED BETWEEN #" & fdate & "# and #" & tdate & "#;"
  4.  
  5. end if
  6.  
Hope this helps.

codegecko
Oct 18 '08 #2
iam_clint
1,208 Expert 1GB
you can use parands to separate these things...

where (blah = blah or blah = 2 or blah = 3) and (cat=1 or cat=2)
Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT * FROM WEB_PRODUCTIVITYDONE WHERE (PROD_USER ='lckatigbak' OR PROD_USER ='jbmarquez') AND (PROD_ENTERED BETWEEN #" & fdate & "# and #" & tdate & "#);" 
  2.  
Oct 20 '08 #3

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

Similar topics

6
by: PG | last post by:
When deleting a row from the database, that id is now missing. So what I'm trying to do is update in a loop (maybe an sql loop if there is one) of all of the id numbers - sort of like renaming...
3
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
3
by: eagleofjade | last post by:
I am trying to help a friend who is learning VB.net in school. I have done VB programming for a number of years using VB 6. He needs to open a query in an Access database that has parameters so he...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
debasisdas
by: debasisdas | last post by:
Using Subqueries ================== The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement. The sub query executes once before the main query. The...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
6
by: BOMEz | last post by:
So i've recently been starting to program PHP in an object oriented way, but I'm running into some difficulties in from a design stand point and from an object oriented stand point: Issue 1: In my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.