|
-
Oct 18th, 2012, 05:44 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Access sql question
i currently have this in my vb 6 app with a access db
Code:
"Select * From BoardSlides WHERE SlideHasDateOnlyDate = -1 AND SlideDisplayOnlyDate = #" & Format(Date, "mm/dd/yyyy") & "# ORDER By SlideName"
so the above only selects records that has date info, "SlideHasDateOnlyDate ", and where that date, "SlideDisplayOnlyDate ", is today and this works great. however i now want to also include records that dont have a date in them, which means it can be displayed on any date, and also select them. is it possible to have it both ways in one select statement?
-
Oct 18th, 2012, 05:53 AM
#2
Re: Access sql question
Use an OR in your Where clause, eg:
Change this:
Code:
AND SlideDisplayOnlyDate = #" & Format(Date, "mm/dd/yyyy") & "#
..to:
Code:
AND (SlideDisplayOnlyDate = #" & Format(Date, "mm/dd/yyyy") & "# OR SlideDisplayOnlyDate Is Null)
-
Oct 18th, 2012, 06:30 AM
#3
Thread Starter
Hyperactive Member
Re: Access sql question
thanks SI, one question. once a value is set to SlideDisplayOnlyDate then the user changes it back to not having a date its no longer null right? so in my update i can force it back to null right?
-
Oct 18th, 2012, 07:03 AM
#4
Re: Access sql question
Make that a test case and try it.
I am pretty sure I know what will happen, but this is something you should be testing for yourself. If your test case fails then you would have an issue we could help you with.
-
Oct 18th, 2012, 08:26 PM
#5
Thread Starter
Hyperactive Member
Re: Access sql question
this is what i went with and it works great. thanks
"Select * From BoardSlides WHERE (SlideHasDateOnlyDate = -1 AND SlideDisplayOnlyDate = #" & Format(Date, "mm/dd/yyyy") & "#) OR SlideHasDateOnlyDate = 0 ORDER By SlideName"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|