Solved

change if statement to include time between two values

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add records to a form to a table 11 41
Access 2016 7 35
Create a EXCEL FIle from Access Procedure 1 19
backup programme - VBA 3 24
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 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