Results 1 to 11 of 11
  1. #1
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141

    Basic Count([Field]) returns Error

    I have a Continuous form populated from Query.
    In the Form Header I have an unbound text Box. I added =Count([StepID]) Then tried =Count([TxtStepID]) (operator name) There are no blanks and the field is numerical... I should return 5 but it returns Error.
    I have successfully used DCount referencing the Query - but it takes too long to populate (because it is a rather complicated set of iifs etc...



    BUT I can't even get the simple Count([StepID]) to work

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The Form Header happens BEFORE there is any data (the data starts being populated in the Detail section).
    So it makes no sense to put the COUNT function there.
    Try putting it in the Footer.

  3. #3
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141
    Originally I had it in the Footer - but got the same issue...

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Might not seem to make sense but Count(*) or Count([fieldname]) in form header works for me.

    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
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141
    CountTest.zip
    Think I have it. The form has the Count in the header and the footer - neither work ( renamed the control object Txt..)

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    another way is

    =Count([InstallID]>0)

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Normally a form does data entry/edit for 1 table. Why are you using this complex a query for this form? Especially since only fields from tblInstalls are needed. Just bind form to TblInstalls.

    TxtStepID is bound to wrong field. Should be ProjectStepID not StepID. Also TxtRepName should be bound to Rep not RepName. Use comboboxes instead of textboxes to select rep and step.

    Make those changes and the Count() works.


    Aggregate functions can only reference fields, not controls.


    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
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    This works for me. I removed some of the txtboxes.
    Included a png of the Form with data.
    Attached Thumbnails Attached Thumbnails TestFormWithCountHdrFtr.PNG  
    Attached Files Attached Files

  9. #9
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Appears to be corruption in the original dB. I created a new dB, then imported all objects from "TEST.accdb".
    After the import, the main form in the new dB matched the image orange posted.(with the exception of the regional settings.... ie Date format )

  10. #10
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141
    Used June's direction no luck - remade it as SSanfo suggested and used June's direction, it worked.
    Wonder if there is a way to un-corrupt the Db

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sometimes yes, sometimes no. Corruption can cause a db to be completely non-functional. Sometimes just requires re-creating an object.

    But I don't think I encountered corruption. After the edits I described, form worked just fine.
    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. IIf returns #error
    By Xray_Chik in forum Access
    Replies: 19
    Last Post: 01-05-2018, 03:38 PM
  2. Need basic advice on using Count in a query
    By Sam_NY in forum Queries
    Replies: 6
    Last Post: 06-05-2015, 09:48 AM
  3. Replies: 14
    Last Post: 03-31-2015, 05:20 PM
  4. Replies: 4
    Last Post: 05-08-2013, 11:56 AM
  5. Field returns error when I import Text Files to Access
    By geng in forum Import/Export Data
    Replies: 3
    Last Post: 06-01-2010, 02:20 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