Results 1 to 5 of 5

Thread: [RESOLVED] Access sql question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Resolved [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?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    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?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    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
  •  



Click Here to Expand Forum to Full Width