Results 1 to 3 of 3
  1. #1
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150

    Aggregate VBA Function with Group By query domain - not allowed

    Hi,

    This is a persistent issue that i'm tired of working around, so i figured i'd finally make an attempt to solve.

    The aggregate VBA function (Dsum) apparently doesn't work when the domain is a group-by query and the field to be calculated (summed) is a calculated expression??

    The error tells me nothing useful (surprise). Documentation also mentions nothing (also shocking).

    Proof is in the download.

    Any ideas, be sure to reach out.

    Thanks




    Database1.zip

  2. #2
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Edit:

    MS did not save my changes when creating the field, thus the function is not finding it, which is why its throwing an error. The query designer is annoying as usual.

    Solved:

    Query was defined by:
    Code:
    db.QueryDefs("Budget_ByCategory").SQL = "SELECT Budget.Category, Sum([MonthlyAmount]/30*" & DaysBetween & ") AS [Period_Expected] FROM Budget GROUP BY Budget.Category;"
    Error line was:
    Code:
    var = DSum("Period_Expected", "Budget_ByCategory")
    Error fixed is:
    Code:
    var = DSum("[Period_Expected]", "Budget_ByCategory")
    Apparently brackets are optional for a field in almost every other part of Access except in functions like dsum - how cool

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,840
    I have experienced this before; never knew what caused it even though I knew enough not to have names that required brackets. Thanks for that.
    I suppose brackets are required in a domain function when the name is an alias. In your case, it is not a field and it is not a control. In my case, I cannot recall because it was too long ago.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 01-26-2020, 02:46 AM
  2. Replies: 2
    Last Post: 01-29-2015, 03:07 PM
  3. Replies: 5
    Last Post: 11-19-2012, 01:44 PM
  4. Replies: 0
    Last Post: 04-25-2011, 07:58 PM
  5. Group by the Emails ISP or Domain Name
    By Shakenaw in forum Access
    Replies: 7
    Last Post: 01-06-2011, 10:07 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