473,480 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
Create 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 1081
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,556 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
1753
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...
6
4459
by: Modest Marsupial | last post by:
What is the DAO method of allowing a recordset to have null values? Thanks, marie
2
6649
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...
3
5793
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...
29
2503
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
2224
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...
1
5089
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...
4
2699
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...
6
6934
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...
0
6920
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...
0
7061
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,...
0
7110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6763
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...
1
4799
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...
0
3015
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...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.