473,608 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I validate user input when asking for a date, but allowing null values

3 New Member
So the goal of my code is to allow a user the option of querying their results using a start and end date (neither are required, but both have to be present for the query to run)

My code for the criteria looks like this:
Expand|Select|Wrap|Line Numbers
  1. Between IIf(IsDate([Forms]![Query Transaction Form]![StartDate]),[Forms]![Query Transaction Form]![StartDate],"*") And IIf(IsDate([Forms]![Query Transaction Form]![EndDate]),[Forms]![Query Transaction Form]![EndDate],"*")
Access keeps telling me its incorrect or too long, what can I do?
Jun 17 '15 #1
5 1084
Seth Schrock
2,965 Recognized Expert Specialist
Based on your form name, I'm going to guess that you have a form with a button to run a query based on the values in the textboxes for your date range. If this is the case, then you are better off doing your validation as a test before running your query. I have never tried it, but I don't think that your query will work using the Between * And * which is what would happen if your data wasn't valid. You may need to change the SQL of your query depending on if there is a date provided or not.
Jun 17 '15 #2
Sardinka
3 New Member
How would I validate beforehand if I am allowing users to not enter a date and run the query based on all date ranges?
Jun 17 '15 #3
jforbes
1,107 Recognized Expert Top Contributor
You might want to look at this as it is similar http://bytes.com/topic/access/answer...es#post3792346
Jun 17 '15 #4
Sardinka
3 New Member
Thank you for all the help! It worked.
Jun 17 '15 #5
NeoPa
32,566 Recognized Expert Moderator MVP
A similar approach might be :
Expand|Select|Wrap|Line Numbers
  1. Between Nz([Forms]![Query Transaction Form]![StartDate],#1/1/1900#) And Nz([Forms]![Query Transaction Form]![EndDate],#12/31/9999#)
Jun 18 '15 #6

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

Similar topics

12
1773
by: D Witherspoon | last post by:
What is the accepted method of creating a data class or business rules object class with properties that will allow the returning of null values? For example... I have a class named CResults with the following properties. TestID int QuestionID int AnswerID int So, this is a simple example, but I want to be able to know if AnswerID is
6
4471
by: Modest Marsupial | last post by:
What is the DAO method of allowing a recordset to have null values? Thanks, marie
2
6666
by: promiscuoustx | last post by:
Hi again all!! I am trying to write my program below to validate user input. In other words, if the user inputs something like "1a2.34", I need to return a message that states invalid data and for them to retry. I am really lost on this one, and I really need some help. Thanks so much!! #include <iostream> #include <iomanip> #include <cmath> #include <cctype> #include <string> #include <sstream> using namespace std;
3
5803
by: Rico | last post by:
Hello, I have a foreign key constraint between two tables (Appointments and MissedAppointmentReasons) and I'd like to allow null values in Appointments table for the field containing the MissedAppointmentReason, but currently, I get a Foreign Key Constraint Error when I try to add a record to the Appointments table. Any ideas how I can have the null values but still maintain the Foreign Key Constraint?
29
2521
parshupooja
by: parshupooja | last post by:
Hi, I am working in Asp.Net 2.0, SQL Server, C#. I am trying to create a User Input form which has lots of fields such as : salutation; Firstname: lastname: address: Zip: Phone:
7
2234
by: Amit | last post by:
Dear Friends I need to write a Java Script for a string payment_code which comes populated from a text field , should contain only 0-9,A-Z,a-z,Space ' ',Hyphen '-',Full stop '.',Comma ',',Plus '+' Characters other than these will not be allowed If a user enters characters other than the mentioned above , the alert message should be displayed
1
5105
by: mzovko20 | last post by:
Hello ! I´m having problem with this. I already created index.html document which allows user to input his/her date of birth. It looks like this : <html> <body> <center> <h3>How old are you ??</h3> <table border="0" width="25%"> <form action="calculate.php" method="get"> <td bgcolor="#FFCC00 ">Your name</td> <td><input type="text" name="name" maxlength="20" value="name"></td>
4
2720
by: ennoil | last post by:
I am requesting user input from a menu a script. The input I am requesting needs to be an integer. Is it possible to validate that the user actually entered an integer and not a string or just hit enter? Everything I have tried will give me "File "<string>", line 0, in ? NameError: name 'd' is not defined The code I have looks like this: def init_menu(): print ''' 0) Exit 1) Environment 2) Use
6
6954
by: michelle eccles | last post by:
I have an array with limit of 5 values. The code as writen allows the user to enter a 6th number before averaging the first five number. I want to stop the user from being able to enter that 6th number. thanks for any help. Code below: using System; public class SumNumbersArray { public static void Main() { int arrayA=new int;
0
8057
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
7998
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
8329
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
6813
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
6010
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
5475
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
3959
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...
0
4022
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1580
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.