Results 1 to 4 of 4
  1. #1
    RAJESHKUMAR R is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    48

    Countiif date with criteria in textbox

    Dear Friends,

    I have a Form which contains a textbox i.e. named as FR_DATE, when user click on the textbox Access allow user to select a Date from Default Calendar

    Support I need here is: -

    The Moment any user selects a date in FR_DATE textbox, keeping selected Date as a Criteria; How many Rows Same Records are available in “FIRMORDERS” Table Ref_Date Column must be counted and gets reflected in Text15 (That is where I have below highlighted Formula).

    Code:
    =IIf([FR_DATE]>0,DCount("[Ref_Date]","FIRMORDERS","[Ref_Date]"="[FR_DATE]"),0)
    Currently Text15 always display Zero Only! Please suggest me with an revised Expression Builder which I can update on Text15 Control Source!

    Thanks & Regards,
    Rajeshkumar R



  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    1. the formula has a 'litteral' in it, dont use quotes around a field that you want a value to resolve:

    =IIf(isnull([FR_DATE]),0,DCount("[Ref_Date]","FIRMORDERS","[Ref_Date]=" & me.FR_DATE ))


    2. i dont see the need for the IIF, if there is no date, it wont resolve either,
    just set the box formula to the count

    =DCount("[Ref_Date]","FIRMORDERS","[Ref_Date]=" & me.FR_DATE))

  3. #3
    RAJESHKUMAR R is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    48
    Dear ranman256,

    Thanks for your instant response and suggestion!

    I understood and choose to use logic of Option 2; Once I paste below Formula, Few red highlighted portions are automatically coming up in Expression Builder!

    Code:
    =DCount("[Ref_Date]","FIRMORDERS","[Ref_Date]=" & [me].[FR_DATE])
    However the Final Result coming is "#Name?"

    Could you please let me what is that I am missing, which doesn't provide correct Result!

    Thanks & Regards,
    Rajeshkumar R


  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Use date delimiters

    Code:
    =DCount("[Ref_Date]","FIRMORDERS","[Ref_Date]=#" & Me.[FR_DATE] & "#")
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 12
    Last Post: 12-25-2015, 12:47 AM
  2. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  3. Replies: 6
    Last Post: 07-24-2014, 04:32 PM
  4. Dlookup with criteria of textbox
    By thescottsman92 in forum Access
    Replies: 3
    Last Post: 08-30-2013, 03:32 AM
  5. Replies: 3
    Last Post: 08-21-2012, 03:05 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