Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Date Range with Null Search
Richard Rost 
      
12 years ago
I received a question from Cesar today:

CESAR:

hi, i need help with the calendar seminar, i created a textbox for a query like a startdate but, i want to show only register that i need for this i put in the properties: SELECT CalendarID, apptime, Description, Hours FROM CAlendarQ WHERE Description = Forms!DatePickerF!Class AND DateTime = Forms!DatePickerF!StartDate and DateTime Forms!DatePickerF!StartDate+1 ORDER BY apptime;
But i want a restriction if i leave the text box empty i want to show them all. How can i do that?
thank you so much

MY REPLY:

First remember that date/time values in an SQL statement need to be enclosed in # signs, so you have:

S = "SELECT * FROM CalendarT WHERE StartDate>#" & Date1 & " AND EndDate<=#" & Date2 & "#"

Now, if you want to show ALL calendar entries are the Date1 and Date2 fields are left blank, you'll need to check for them:

If IsNull(Date1) AND IsNull(Date2) Then
  S = "SELECT * FROM CalendarT"
Else
  S = 'above statement
End if

Easy enough? For more tricks like this, I recommend my SQL Seminar and/or my Search Seminar which both go into a LOT of custom SQL writing.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/17/2026 6:41:03 AM. PLT: 0s