Help with IF statment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 7 of 9
    New Member
    • May 2007
    • 23

    Help with IF statment

    Hello All,

    Here is my problem. I want to write code in VBA for an access DB macro that will (based on the day of the week) run 1 of 2 queries but I don’t know how to go about doing it. Here is what I mean:

    IF today is Monday
    THEN run qry1
    ELSE run qry2

    How do I do this?
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by 7 of 9
    Hello All,

    Here is my problem. I want to write code in VBA for an access DB macro that will (based on the day of the week) run 1 of 2 queries but I don’t know how to go about doing it. Here is what I mean:

    IF today is Monday
    THEN run qry1
    ELSE run qry2

    How do I do this?
    VB has a format function for dates that returns the day of the week based on a number. I think Monday is 2.

    Then you are also going to have to format the actual date returned by a date function....

    So..

    If (Format(Now( ), "dddd")) = "Monday" then
    do query
    else
    do other query
    end if

    All kind of tutorials on this kind of formatting at:

    Comment

    • 7 of 9
      New Member
      • May 2007
      • 23

      #3
      Originally posted by jeffstl
      VB has a format function for dates that returns the day of the week based on a number. I think Monday is 2.

      Then you are also going to have to format the actual date returned by a date function....

      So..

      If (Format(Now( ), "dddd")) = "Monday" then
      do query
      else
      do other query
      end if

      All kind of tutorials on this kind of formatting at:

      http://www.google.com/search?hl=en&q...rmat%28Date%2C
      Thanks, and sorry for the delay.

      Comment

      Working...