Solved

change if statement to include time between two values

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now