Solved

change if statement to include time between two values

Posted on 2012-03-11
2
311 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

856 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