Record Locking if time is after 7am and 7pm

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • colemanj4

    Record Locking if time is after 7am and 7pm

    Hello,

    I am trying to lock fields based on the time in a date/time field. I
    want them to lock if if they were entered before 7am and then again if
    before 7pm. I am not too good at dealing with dates and times in VBA
    so I was wondering if anyone here could help me out. Below is my dt
    variable being compared to "now" and then locking if greater then an
    hour.

    If DateDiff("n", dtEnteredOn, Now()) 60& Then
    bLock = True
    End If

    Let me know if you need more information.

    Thanks
  • Tom van Stiphout

    #2
    Re: Record Locking if time is after 7am and 7pm

    On Fri, 29 Feb 2008 12:48:51 -0800 (PST), colemanj4
    <colemanj4@gmai l.comwrote:

    I think you meant to write "AFTER 7pm"

    I would use the Hour function:
    bLock = (Hour(dtEntered On)<7 or Hour(dtEnteredO n)>=19)

    -Tom.


    >Hello,
    >
    >I am trying to lock fields based on the time in a date/time field. I
    >want them to lock if if they were entered before 7am and then again if
    >before 7pm. I am not too good at dealing with dates and times in VBA
    >so I was wondering if anyone here could help me out. Below is my dt
    >variable being compared to "now" and then locking if greater then an
    >hour.
    >
    If DateDiff("n", dtEnteredOn, Now()) 60& Then
    bLock = True
    End If
    >
    >Let me know if you need more information.
    >
    >Thanks

    Comment

    Working...