473,800 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query with an option

I have a query that searches for classes held between a date range:

SELECT EMP_NAMES.LNAME , EMP_NAMES.FNAME , TRAINING.CLASS_ ATTD, TRAINING.DATE_A TTD
FROM EMP_NAMES INNER JOIN TRAINING ON EMP_NAMES.UID = TRAINING.UID
WHERE (((TRAINING.CLA SS_ATTD) Like ([Enter it the name of the class])) AND ((TRAINING.DATE _ATTD) Between DateValue([Enter the beginning date]) And DateValue([Enter the cutoff date])));

Currently the user MUST enter a date in the date range boxes. What I would like to happen is: If the user hits the enter key (puts nothing in the date boxes) the query continues and reports information containing class information for ALL dates. I'm sure this is a relatively simple IFF statement but, I'm kinda new at this stuff and don't quite know how to state it.

Thanks for your help in advance.

*************** *************** ***********
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...9255f3976e2fa7
*************** *************** ***********
Nov 13 '05 #1
10 1442
Gary Toth via AccessMonster.c om wrote:
I have a query that searches for classes held between a date range:

SELECT EMP_NAMES.LNAME , EMP_NAMES.FNAME , TRAINING.CLASS_ ATTD, TRAINING.DATE_A TTD
FROM EMP_NAMES INNER JOIN TRAINING ON EMP_NAMES.UID = TRAINING.UID
WHERE (((TRAINING.CLA SS_ATTD) Like ([Enter it the name of the class])) AND ((TRAINING.DATE _ATTD) Between DateValue([Enter the beginning date]) And DateValue([Enter the cutoff date])));

Currently the user MUST enter a date in the date range boxes. What I would like to happen is: If the user hits the enter key (puts nothing in the date boxes) the query continues and reports information containing class information for ALL dates. I'm sure this is a relatively simple IFF statement but, I'm kinda new at this stuff and don't quite know how to state it.

Thanks for your help in advance.

*************** *************** ***********
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...9255f3976e2fa7
*************** *************** ***********


Here is an example. In the where, I test for start and end. If start
and end are not null, the range is selected. Otherwise it checks for
the status of start and end to see if it is null. Thus there are 4
criteria; Start/End filled in, Start filled in only, End filled in only,
or both weren't filled in.

SELECT Table1.DateFiel d
FROM Table1
WHERE (Table1.DateFie ld) Between [Enter Start] And [Enter End]) OR _
(Table1.DateFie ld>=[Enter Start] And [Enter End] Is Null) OR _
([Enter Start] Is Null And Table1.DateFiel d<=[Enter End]) OR _
([Enter Start] Is Null And [Enter End] Is Null);
Nov 13 '05 #2
"Gary Toth via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in message
news:34******** *************** *******@AccessM onster.com...
I have a query that searches for classes held between a date range:

SELECT EMP_NAMES.LNAME , EMP_NAMES.FNAME , TRAINING.CLASS_ ATTD,
TRAINING.DATE_A TTD
FROM EMP_NAMES INNER JOIN TRAINING ON EMP_NAMES.UID = TRAINING.UID
WHERE (((TRAINING.CLA SS_ATTD) Like ([Enter it the name of the class])) AND
((TRAINING.DATE _ATTD) Between DateValue([Enter the beginning date]) And
DateValue([Enter the cutoff date])));

Currently the user MUST enter a date in the date range boxes. What I
would like to happen is: If the user hits the enter key (puts nothing in
the date boxes) the query continues and reports information containing
class information for ALL dates. I'm sure this is a relatively simple IFF
statement but, I'm kinda new at this stuff and don't quite know how to
state it.

Thanks for your help in advance.

*************** *************** ***********
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
*
http://www.accessmonster.com/Uwe/Abu...9255f3976e2fa7
*************** *************** ***********


select EMP_NAMES.LNAME , EMP_NAMES.FNAME , TRAINING.CLASS_ ATTD,
TRAINING.DATE_A TTD
from EMP_NAMES INNER JOIN TRAINING ON EMP_NAMES.UID = TRAINING.UID
where
(
TRAINING.CLASS_ ATTD Like [Enter it the name of the class]
)
and
(
(
TRAINING.DATE_A TTD >= [Enter the beginning date] or [Enter the
beginning date] Is Null
)
and
(
TRAINING.DATE_A TTD <= [Enter the cutoff date] or [Enter the
cutoff date] Is Null
)
)
--
Your eyes will probably thank you if you stop using all caps for your table
and column names :)




Nov 13 '05 #3
B I N G O!

Thanks a LOT!!

*************** *************** ***********
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/For...s-access/17425
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...7d0cb11a882f92
*************** *************** ***********
Nov 13 '05 #4
This works well. However, I'm getting extra date range prompts. The one sent by Salad only works if I DON'T put a date range in.

*************** *************** ***********
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/For...s-access/17425
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...bc9b19f3e358c5
*************** *************** ***********
Nov 13 '05 #5
Gary Toth via AccessMonster.c om wrote:
This works well. However, I'm getting extra date range prompts. The one sent by Salad only works if I DON'T put a date range in.

*************** *************** ***********
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/For...s-access/17425
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...bc9b19f3e358c5
*************** *************** ***********


If mine is failing...make sure the _ are removed. I have OR _ in my
code. In a query builder you don't want them.

Create a table called Table1. It should have 1 field; DateField, type
Date. Enter 5 records; 1/1/2004 to 1/5/2004. Now create a new query.
Go to ViewSQL from the menu and drop this in

SELECT Table1.DateFiel d
FROM Table1
WHERE (Table1.DateFie ld) Between [Enter Start] And [Enter End]) OR
(Table1.DateFie ld>=[Enter Start] And [Enter End] Is Null) OR
([Enter Start] Is Null And Table1.DateFiel d<=[Enter End]) OR
([Enter Start] Is Null And [Enter End] Is Null);

It works for me. You'll notice there are no underbars
Nov 13 '05 #6
"Gary Toth via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in message
news:c0******** *************** *******@AccessM onster.com...
This works well. However, I'm getting extra date range prompts. The one
sent by Salad only works if I DON'T put a date range in.


Make sure the startt and end date range parameters are all equivalent -
probably a typo somewhere
Nov 13 '05 #7
Checked it over and can't find anything.

FWIW, the prompt in the second box is cut of so it says "Enter the"

If I just hit enter through the second set of prompts, it works fine.

*************** *************** ***********
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/For...s-access/17425
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...5fbb5801033904
*************** *************** ***********
Nov 13 '05 #8
This is how I got it working...

SELECT EMP_NAMES.LNAME , EMP_NAMES.FNAME , TRAINING.CLASS_ ATTD, TRAINING.DATE_A TTD
FROM EMP_NAMES INNER JOIN TRAINING ON EMP_NAMES.UID = TRAINING.UID
WHERE (
TRAINING.DATE_A TTD >= [Enter the beginning date] or [Enter the beginning date] Is Null

)
and
(
(
TRAINING.DATE_A TTD <= [Enter the cutoff date] or [Enter the cutoff date] Is Null
)
and
(
TRAINING.CLASS_ ATTD Like [Enter the name of the class]
)
);
Thanks tons!!

*************** *************** ***********
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/For...s-access/17425
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...b353e810e6b26e
*************** *************** ***********
Nov 13 '05 #9
"Gary Toth via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in message
news:dc******** *************** *******@AccessM onster.com...
Checked it over and can't find anything.

FWIW, the prompt in the second box is cut of so it says "Enter the"


Line-wrap is the problem
Nov 13 '05 #10

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

Similar topics

3
5399
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1.""; ERROR: Invalid query: You have an error in your SQL syntax near '=' at line 1
2
5689
by: JDJones | last post by:
Using PHP and MySQL. Trying to put a list of categories into a drop down select option of a form like: <form name="form" action="<? print $_SERVER?>" method="get"> <select name="subject"> <option value=""></option> <option value="field1">Field 1</option> <option value="field2">Field 2</option> </select>
4
1982
by: Joe | last post by:
I have wrote a script to query my mysql database based up a name that is selected from an HTML list menu, the form action calls to my php script from my html doc, I have tested connectivity to the databse and have added a manual sql query to my php script to be sure it is functioning properly, the problem is I'm not sure how to get the script to see what option the html form is sending, I thought I could use: $query = "SELECT * FROM...
13
2893
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine. Value selected is used as the 'where' clause of the 2nd query. If $site is a single word, the 2nd query works like a charm. If $site is more than one word (has spaces), the query returns a null
7
2218
by: stig | last post by:
hi. coming from postgresql, i am used to textual references to most of the things i do with the database. i feel a little lost with all the graphical. i have few questions regarding MS SQL 2000 1. what is the best (or easiest) way of getting a table definition in text? it could be either a CREATE TABLE sql-query or a just a definition, something like: TABLE thisTable id integer
3
30291
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in multiple fields. I don't have the option of changing the structure of the existing tables because I am importing them from a separate data source on a regular basis. I also need to use a query instead of a form because I then need to be able to export...
0
3308
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex queries yes or no, I have prepared an example. The example is a database with the following tables: *table person with fields: -persid: autoincrement id -name: name of the person *table material with fields: -materialid: autoincrement id
4
6503
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box. When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category. However when i check multiple checkboxes and...
4
11906
by: Joe | last post by:
This is my HTML form: <form method=get action="home.php"> <INPUT TYPE = "Text" VALUE = "" NAME = "title"><br> <select name="searchby"> <option value="Title">Title</option> <option value="Year">Year</option> <option value="Genre">Genre</option> <option value="Director">Director</option> </select>
11
4098
beacon
by: beacon | last post by:
Hi everybody, I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time (that's just bonus background info). I take this table, which is read-only, and run an APPEND query that adds new items from the table into another table I created (that has two additional fields that will be updated by the user via a form). I also...
0
9690
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
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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...
1
7576
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
6811
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
5469
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.