Results 1 to 4 of 4
  1. #1
    terbs is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    2

    Count function in Query always Read Only?

    I have added several counts/sums to an existing query my company uses on our switchboard. Since then the query has become Read Only, which is a problem because it needs to be updateable.



    Is there any work around I can use to allow me to have a count within a query while still being updateable? I have tried using DCount, but its way to inefficient, the screen refreshes like 3-4 times before anything can be used.

    Here is my query if someone could suggest a change.

    Code:
    SELECT x.EMPINITIALS, x.EMPNAME, x.EMPLOYEEID, x.Version, DEFAULTS.repdate, x.status, x.comments, x.State, 
     
    (SELECT Count(y.CallNumber) 
    FROM TABservice as y 
    WHERE y.Engineer = x.EMPINITIALS AND y.DateLogged > #1/1/2010#) AS CallCount, 
     
    (SELECT Count(y.ID) 
    FROM TBLServiceCallItem as y 
    WHERE y.Engineer = x.EMPINITIALS AND y.Date >#1/1/2010#) AS JobCount, 
     
    (SELECT Round(Sum(y.LabourTime),1) 
    FROM TBLServiceCallItem as y 
    WHERE y.Engineer = x.EMPINITIALS AND y.Date>Date()-7) AS LabourSum, 
     
    (SELECT Round(Sum(y.TravelTime),1) 
    FROM TBLServiceCallItem as y 
    WHERE y.Engineer = x.EMPINITIALS AND y.Date>Date()-7) AS TravelSum
     
    FROM DEFAULTS INNER JOIN TBLEmployee AS x ON DEFAULTS.BRANCHID = x.EMPLOYEEID
     
    WHERE (((x.EMPLOYEEID)>9) AND ((x.CURRENT)=True))
     
    ORDER BY x.State;

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Yes, queries that aggregate records are read-only. They are read only because the records are ambuguous and Access would have no idea which record to update. Where did you have the DCount()? Was it the ControlSource of a control on your form?

  3. #3
    terbs is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Posts
    2
    No basically just

    SELECT x.field, MyCount: DCount("[Field]","[Table]","[x] = " & [FieldX]), xfield2 etc etc

    Thanks for your reply anyway have found a solution, not that im really happy with it.

    I suggested adding fields to the database and updating them on open, but my boss is happy with a second subform adjacent to the existing. Messy option in my mind.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So you are displaying the various counts in another SubForm on your form? Hard to envision but sounds like a useful solution. Thanks for posting back with your solution.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-18-2009, 06:49 PM
  2. Running Count Query
    By monkey2003 in forum Queries
    Replies: 0
    Last Post: 09-21-2009, 12:24 PM
  3. Result of Count Query not known elsewhere
    By Carole in forum Access
    Replies: 1
    Last Post: 09-07-2008, 09:39 AM
  4. Query using count function
    By wasim_sono in forum Queries
    Replies: 0
    Last Post: 11-28-2007, 03:16 AM
  5. Replies: 2
    Last Post: 10-19-2006, 04:37 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