A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

#Error in Expression



 
 
Thread Tools Display Modes
  #1  
Old September 14th, 2009, 02:49 PM posted to microsoft.public.access.reports
Gsurfdude
external usenet poster
 
Posts: 11
Default #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  
Old September 14th, 2009, 03:18 PM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default #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  
Old September 14th, 2009, 03:40 PM posted to microsoft.public.access.reports
Gsurfdude
external usenet poster
 
Posts: 11
Default #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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.