Results 1 to 4 of 4
  1. #1
    Bosworth is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    6

    Compare dates in 2 unbound text boxes

    On a form I'm asking a user to enter dates in 2 different textboxes, say, [text1] and [text2], both formatted to short date. In a third textbox [text3] I need to see the date of the greater of the two, and in a fourth [text4] I need to see the date of [text3] if it falls on a Monday through Friday, or the date of the previous Friday if [text3] falls on Saturday, and the date of the following Monday if [text3] falls on a Sunday.

    ...a couple quick examples;

    If text1 = 2/20/2015 and text2 = 2/27/2015, text3 should evaluate to 2/27/2015, and text4 should evaluate to 2/27/2015
    or
    If text1 = 2/20/2015 and text2 = 2/28/2015, text3 should evaluate to 2/28/2015, and text4 should evaluate to 2/27/2015


    My attempts to compare text1 and text2 revolve around an IIF but result in an error...

    Entering this into [text3]... IIF([text1]>[text2], [text1], [text2])

    ...results in "#Name?" error, which I interpret as meaning the date from the source cannot be pulled into the formula.

    In attempt to check the day of week, I used =Weekday([text3],1) which results in a number. I haven't been able to do an IIF on it as it errors with #Name? again. I've tried a couple other ideas but nothing is bearing fruit. Please give me a nudge in the right direction.

    TIA
    Bos

  2. #2
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    try # around the dates. #1/1/2015#

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    #Name? means Access can't find something that is referenced in the expression. Make sure names are spelled correctly and that you have = sign at beginning of the expression.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Bosworth is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    6
    Thank you Trevor40 and June7.

    Amazing what happens when you use the right syntax. Just needed the "=" in front of the IFF. Should have known better.

    Bos

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

Similar Threads

  1. Unbound text boxes show #ERROR on data entry line
    By GraeagleBill in forum Forms
    Replies: 4
    Last Post: 01-07-2015, 12:44 AM
  2. Replies: 3
    Last Post: 12-17-2013, 05:14 AM
  3. Replies: 4
    Last Post: 08-14-2012, 10:33 AM
  4. Using Unbound text boxes
    By rbiggs in forum Reports
    Replies: 4
    Last Post: 08-16-2011, 04:05 PM
  5. Unbound Text boxes
    By kyleg222 in forum Forms
    Replies: 2
    Last Post: 08-02-2011, 12:53 PM

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