Results 1 to 6 of 6
  1. #1
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46

    Missing Bracket/Parenthesis in Expression on Form

    Hello - I have been working on this one part of my database for the past week and might be going crazy but I tried entering an expression into a textbox:



    =iif([Function]="Business",(sum([Total Curr])/sum([Total PY])-1),"")

    and keep getting the error message that my expression is missing a closing parenthesis, bracket or vertical bar. I can't figure out what is missing in the formula though?????

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Looks okay to me, and entering it into a textbox doesn't produce an error. Are you sure the error isn't coming from someplace else? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46
    I exited out of my database and then re-tried the formula again and it works now...strange. not sure what was causing the error message. However, now I am getting blanks in the values because of my expression, which ends with =iif([Function]="Business",(sum([Total Curr])/sum([Total PY1])-1),""). When I go into the query that the form is based off of however, there is very much a value. Why is my expression not working?
    Click image for larger version. 

Name:	Crosstab query example.JPG 
Views:	17 
Size:	30.0 KB 
ID:	19217

    Pic above shows the crosstab query - the columns across (Business, A, B, C, etc) are from the field "Function".

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There is a difference in the two expressions:
    Post #1:
    =iif([Function]="Business",(sum([Total Curr])/sum([Total PY])-1),"")
    Post #3:
    =iif([Function]="Business",(sum([Total Curr])/sum([Total PY1])-1),"")

    Sometimes Access does not provide, ummm, lets say 'accurate' error messages.

    Not sure why you are getting the blanks.

    BUT....... "Function" is a reserved word in ACCESS and shouldn't be used for object names.
    Also, you shouldn't use spaces in object names. Either "TotalCurr" or "Total_Curr" (underscore) would be a better name.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why would you return an empty string to a number field? Return 0 or Null instead.

    Are you sure SBU2 has "Business" records?
    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.

  6. #6
    accessnewbie352 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    46
    Quote Originally Posted by June7 View Post
    Why would you return an empty string to a number field? Return 0 or Null instead.

    Are you sure SBU2 has "Business" records?
    Sorry, maybe I wasn't clear - the spreadsheet view is the crosstab query I am trying to base my form off of and shows the correct values. I want to show blank where there are no values but even if SBU2 does not have a business record, I am trying to find the total for all Businesses (so sum of SBU1 - BUsiness, SBU2 - Business, SBU3 - Business, etc).

    I don't want to return 0 because I don't want there to be a visible text in the form view when there is no actual value. Will try the Null but not sure if that will fix the issue?

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

Similar Threads

  1. Replies: 4
    Last Post: 10-03-2014, 07:31 AM
  2. Replies: 6
    Last Post: 03-27-2014, 09:43 AM
  3. Replies: 2
    Last Post: 02-17-2014, 10:27 AM
  4. Replies: 9
    Last Post: 01-22-2013, 04:23 PM
  5. Missing a parenthesis somewhere in query
    By johnmerlino in forum Reports
    Replies: 12
    Last Post: 12-21-2010, 08:34 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