Results 1 to 3 of 3
  1. #1
    diods87 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    3

    Access Macro Design - "if" Statement, Access 2010

    Hi all,



    I wonder if you could help me out with this one.
    I am trying to create an "IF"/"Else" statement in a macro design of my database.
    What I am looking for is to apply the IF statement to the current time. Is there a function called "systime" or similiar? I want the IF to look at the current time, and if it is before 2pm, run the query below, ELSE, only come come up with a message box.
    BEFORE I used the below which was looking at the "YES" or "NO" appearing in my table, however I need it to be looking at the current time, cause I do not want some data to be processed if it is after 2pm...

    Click image for larger version. 

Name:	Capture1.JPG 
Views:	20 
Size:	25.7 KB 
ID:	14324



    Hope you know what I am talking about?
    Any help/hints would be much appreciated.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try something like this:
    Code:
    If Hour(Now()) < 14 Then
    ...
    Note that NOW() returns the current data and time, and the Hour function pulls just the hour component out of it.
    The hours are returned in military format, so 2 PM equates to 14.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There is also the Time() function. Returns just the current time.

    Code:
    If Hour(Time()) < 14 Then
    ....
    The results will be the same as Joe's code snippet.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 06-26-2013, 02:29 PM
  2. Replies: 3
    Last Post: 02-01-2013, 01:11 PM
  3. Replies: 3
    Last Post: 07-19-2012, 06:22 AM
  4. Replies: 2
    Last Post: 11-04-2011, 02:45 AM
  5. Get "My Documents" in Access 2007 macro
    By RMittelman in forum Programming
    Replies: 7
    Last Post: 10-31-2011, 03:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums