If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
#Error in Expression
Hello,
On an report, I get an "#Error" in the text box control who's Control Source is set to this expression. =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I'),[qry_449_Report]![SECTION_LENGTH],0)) But, I do not get this error with this one (identical to above except [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I') is not in the expression E.G. This works... =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H'),[qry_449_Report]![SECTION_LENGTH],0)) I am a little stumped why even tho syntax looks OK in the one I get the error |
#2
|
|||
|
|||
#Error in Expression
Suggestions:
1. You don't need the query name in the expression (unless the field name is ambiguous.) 2. The IN operator might be easier than repeating the ORs. Try: =Sum(IIf([ROUTE_TYPE]=1 AND ([DIV_HWY_SURF_TYPE] IN ('G','H','I') OR [UDIV_HWY_SURFACE_TYPE] IN ('G','H','I')) [SECTION_LENGTH], 0)) This assumes that: a) Route_Type and Section_Length are Number type fields; b) the DIV... and UDIV fields are Text type. c) You have text boxes on your report for all 4 fields (even if hidden.) -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Gsurfdude" wrote in message ... Hello, On an report, I get an "#Error" in the text box control who's Control Source is set to this expression. =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I'),[qry_449_Report]![SECTION_LENGTH],0)) But, I do not get this error with this one (identical to above except [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I') is not in the expression E.G. This works... =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H'),[qry_449_Report]![SECTION_LENGTH],0)) I am a little stumped why even tho syntax looks OK in the one I get the error |
#3
|
|||
|
|||
#Error in Expression
Worked! Thank you.
"Allen Browne" wrote: Suggestions: 1. You don't need the query name in the expression (unless the field name is ambiguous.) 2. The IN operator might be easier than repeating the ORs. Try: =Sum(IIf([ROUTE_TYPE]=1 AND ([DIV_HWY_SURF_TYPE] IN ('G','H','I') OR [UDIV_HWY_SURFACE_TYPE] IN ('G','H','I')) [SECTION_LENGTH], 0)) This assumes that: a) Route_Type and Section_Length are Number type fields; b) the DIV... and UDIV fields are Text type. c) You have text boxes on your report for all 4 fields (even if hidden.) -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Gsurfdude" wrote in message ... Hello, On an report, I get an "#Error" in the text box control who's Control Source is set to this expression. =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I'),[qry_449_Report]![SECTION_LENGTH],0)) But, I do not get this error with this one (identical to above except [qry_449_Report]![DIV_HWY_SURF_TYPE]='I' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='I') is not in the expression E.G. This works... =Sum(IIf([qry_449_Report]![ROUTE_TYPE]=1 And ([qry_449_Report]![DIV_HWY_SURF_TYPE]='G' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='G' Or [qry_449_Report]![DIV_HWY_SURF_TYPE]='H' Or [qry_449_Report]![UDIV_HWY_SURFACE_TYPE]='H'),[qry_449_Report]![SECTION_LENGTH],0)) I am a little stumped why even tho syntax looks OK in the one I get the error |
Thread Tools | |
Display Modes | |
|
|