Results 1 to 6 of 6
  1. #1
    Bluecider is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    6

    Navigation Subforms with Dcount Control Source Referring to Date Range

    Well.. I'm stumped.



    I have a main form 'frm_MAIN' which calls a subform 'frm_STATS' from a Navigation Control on the main form.

    Within the 'frm_STATS' I have a text box where I'm trying to report the number of records from table 'tbl_JOBS' based on a date range (two text boxes with date picker) on the same form 'frm_STATS'.
    Date From textbox = 'mndate'
    Date To textbox = 'mxdate'

    Here is my control source dcount:

    =DCount("*","tbl_JOBS","[CreationDate] between DateValue('" & [Forms]![frm_MAIN].[NavigationSubform].[Form].[mndate] & "') AND DateValue('" & [Forms]![frm_MAIN].[NavigationSubform].[mxdate] & "')")

    I'm getting a #Name? error in the text box where the Dcount exists above.

    Any ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Date parameters use # delimiter not ' .

    I don't see anything else wrong with syntax referencing textbox.
    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
    Bluecider is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    6
    Still yields same error #Name?

    =DCount("*","tbl_JOBS","[CreationDate] between DateValue(#" & [Forms]![frm_MAIN].[NavigationSubform].[Form].[mndate] & "#) AND DateValue(#" & [Forms]![frm_MAIN].[NavigationSubform].[mxdate] & "#)")

    Now, I know that maybe this isn't the most elegant way to do this. Though I just wanted to save myself pushing the results via VBA into the text boxes.

    When opening the subform 'frm_STATS' by itself, I had no error with doing this:

    =DCount("*","tbl_JOBS","[CreationDate] between DateValue('" & [Forms]![frm_STATS].[mndate] & "') AND DateValue('" & [Forms]![frm_STATS].[mxdate] & "')")

    So I think it's something to do with calling the subform which is within the navigational controls 'NavigationSubform'

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    CreationDate is a date/time type field?

    I was afraid Navigation Form was the primary issue. I have never used them because they are trickier to reference. Review https://www.accessforums.net/showthread.php?t=32053

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  5. #5
    Bluecider is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    6
    Ok... Got it to work:


    =DCount("*","tbl_JOBS","[CreationDate] between DateValue('" &Forms![frm_MAIN].NavigationSubform.Form.[mndate] & "') AND DateValue('" & Forms![frm_MAIN].NavigationSubform.Form.[mxdate] & "')")

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Glad you got it working. However, aside from removing some []'s which should not matter in this case, I don't see any difference from the original syntax.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 02-24-2016, 08:51 PM
  2. dCount by date range
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 10-09-2013, 09:48 PM
  3. Reports with Date Range in Navigation Form
    By crix_17 in forum Reports
    Replies: 0
    Last Post: 08-07-2013, 05:21 AM
  4. Referring to range in access
    By ped in forum Access
    Replies: 11
    Last Post: 08-10-2011, 04:22 PM
  5. Using a date range with Dcount function
    By mleberso in forum Reports
    Replies: 4
    Last Post: 06-17-2011, 08:56 AM

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