Solved

change if statement to include time between two values

Posted on 2012-03-11
2
312 Views
Last Modified: 2012-03-12
Hello,
will paste part of code here:
is there a way to change to a between statement - between 1 and 4:30?

Dim one As Date
Dim strMessage As String
Dim strControlIn As String
Dim strControlOut As String
Dim strButton As String
Dim strText As String
Dim strLIn As String
Dim strLOut As String

    one = Now
   
    strControlIn = "txtFriIn"
    strControlOut = "txtFriOut"
    strButton = "cmdFriOut"
    strText = "txtReg5"
    strLIn = "txtFriLin"
    strLOut = "txtFriLout"
   
    If TimeValue(one) >= #1:00:01 PM# And Weekday(one) = vbFriday Then
        strMessage = "Leaving at " & one & " Logged as 4.30pm"
    Else
        strMessage = "Leaving at " & one
    End If
   
Right now the code clocks anybody who clocks out after 1:00 on friday- at 4:30
I need to change it to say clock anybody who clocks out after 1:00 and not later than 4:30-at 4:30---------( but if they clock out later than 4:30- then it should go back to clocking out real time-now()
thank you
0
Comment
Question by:davetough
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37708153
Try this:

If TimeValue(one) >= #1:00:01 PM#  And TimeValue(one) <= #4:30:00 PM# And Weekday(one) = vbFriday Then

'etc.
0
 

Author Closing Comment

by:davetough
ID: 37709088
thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Filter Date on Split Form 8 30
Access Report Expression 4 25
Access query error 3 23
Open folder via explorer, but stop user from changing folder 5 10
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question