Results 1 to 2 of 2
  1. #1
    Larry819 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    1

    Time Comparison

    We are using a form for data entry of results which can be used by multiple people. We have no security set up as of yet on the DB. We have a field called technician in on of our forms where the person doing the entry type their name. We want to build an expression in the default value to work as follows: if the current time is between 7am and 3pm, then John Doe, then Jane Doe. This is a simplified version, but I am having trouble getting the right syntax. I could also make the field a list box and have the individual just choose their name, but would prefer the method above. Thanks for the help

  2. #2
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Create a Table Technician to have field
    TPerson (if you haven't yet)
    to store all technician names:
    John Doe
    Jane Doe

    Create a comboBox cboT on the input form to store the technician name.

    Set its datasource as
    Code:
    SELECT Technician.TPerson FROM Technician ORDER BY Technician.TPerson;
    Set its default as a function
    =CurrTech()

    Code:
    Function CurrTech()
    hr = Hour(Now())
     
    If hr >= 7 And hr < 15 Then
    CurrTech = "John Doe"
    Else
    CurrTech = "Jane Doe"
    End If
    End Function

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums