Results 1 to 8 of 8
  1. #1
    Benj is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    33

    Date Field

    Good day! i have 2 fields with row source: SELECT SowTags.[Sow Id], SowTags.[Due date] FROM SowTags ORDER BY SowTags.[Sow Id];
    field 1 shows the [SowTag]
    field 2 shows the [Due date] and is not enabled



    then i have a text box =abs([DateEntered]-[Due date]). result would be either #Type! or a date like Aug-4-16

    Thanks in advance!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    You have two comboboxes on form? Why would two fields/comboboxes have the same RowSource?

    I expect both actually have value of [Sow Id]. But would have to see other combobox properties to confirm (ColumnCount, BoundColumn, ColumnWidths).

    Textbox expression can pull [Due date] from combobox column by referencing column index. Index begins with 0. Name combobox different from field, like cbxID.

    =Abs([DateEntered]-[cbxID].Column(1))

    Note that calculation will not include start date. 12/30/2019 - 12/27/2019 will return 3, not 4. Therefore 12/27/2019 - 12/27/2019 will return 0. In your case, this might be what you want.


    Advise not to use spaces in naming convention.
    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.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What's the question? You realize your calculation results in a number, not a date (the number of days between the 2 dates). The textbox should not be formatted as a date. The error may result when one of the fields is Null (blank).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Benj is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    33
    ComboBox1: would show [SowID] (enabled, ColumnCount 2, BoundColumn 1, ColumnWidth 1";0")
    ComboBox2: automatically sows [DueDate] (thanks for the advise on no spaces, NOT ENABLED, Format ShortDate, ColumnCount 2, BoundColumn 1, ColumnWidth 0";1")

    I removed ComboBox2

    I typed unto TextBox1 your suggestion =Abs([DateEntered]-[SowID].Column(1)) but it would change to =Abs([DateEntered]-[SowID].[Column](1)) and would still show #Type!

    Thanks in advance!

  5. #5
    Benj is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    33
    The outcome i was hoping for was the difference between two dates, which would be a number. Yes the textbox is a general number and not formatted as a date. Thanks for the reply!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Sorry, have to convert combobox string value to date:

    =Abs([DateEntered]-CDate([cbxID].[Column](1)))

    Yes, Access will throw in the [ ] if you omit.
    Last edited by June7; 07-19-2019 at 12:07 PM.
    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.

  8. #8
    Benj is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    33
    Thanks so much!

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

Similar Threads

  1. Replies: 5
    Last Post: 04-20-2018, 01:33 PM
  2. Replies: 1
    Last Post: 04-29-2016, 04:03 AM
  3. Replies: 6
    Last Post: 06-26-2015, 08:55 PM
  4. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  5. Replies: 2
    Last Post: 05-22-2014, 06:11 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