Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
General
 MetaMatica Forum : General
Subject Topic: arguments for IF Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 07 June 2007 at 3:59am | IP Logged Quote SteveW

I am trying to create an expression but I keep getting a 'Wrong arguments for IF' error message. Please can you tell me where I'm going wrong. These are all expression I've tried and all have failed:

IF(UNIT_NUMBER = "","",UNIT_NUMBER + CHR(13) + CHR(10))
IF(UNIT_NUMBER = " "," ",UNIT_NUMBER + CHR(13) + CHR(10))
IF(UNIT_NUMBER = "", "A", "B")
IF(STRLEN(UNIT_NUMBER) = 0,"",UNIT_NUMBER + CHR(13) + CHR(10))
IF(STRLEN(UNIT_NUMBER) = 0, "A", "B")
IF(ISNULL(SalesInvoice, UNIT_NUMBER),"",UNIT_NUMBER + CHR(13) + CHR(10))

I have also tried creating a variable to hold the length of UNIT_NUMBER but the 'User Defined Functions Editor' window has no OK button and does not close when I click the cross.

What I'm trying to achieve is to concatenate several fields with a line return in between but I only want to include fields if they contain a value.
Back to Top View SteveW's Profile Search for other posts by SteveW
 
administrator
Admin Group
Admin Group
Avatar

Joined: 01 October 2003
Online Status: Offline
Posts: 46
Posted: 07 June 2007 at 5:53am | IP Logged Quote administrator

You must use single quotas for strings in your expression
For example:
IF(Dataset1.Code < 200, 'less', 'MORE')

What are variables UNIT_NUMBER and SalesInvoice? If you want to use dataset field you have to use the following format:
<DatasetName>.<FieldName>
DatasetName you can see in report datasets (menu Report -> Datasets) in the report designer. It is not a table name.

Also try to use expression builder to learn more.



__________________
Oleg Yershov
Back to Top View administrator's Profile Search for other posts by administrator Visit administrator's Homepage
 
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 07 June 2007 at 6:42am | IP Logged Quote SteveW

Thanks for your help Oleg

administrator wrote:
You must use single quotas for strings in your expression
For example:
IF(Dataset1.Code < 200, 'less', 'MORE')
You may wish to correct the examples in the help file:
if(AmountPaid > 5000, "Large order", "Small order")   
if(CheckField, "X", " ")

administrator wrote:
What are variables UNIT_NUMBER and SalesInvoice? If you want to use dataset field you have to use the following format:
<DatasetName>.<FieldName>
DatasetName you can see in report datasets (menu Report -> Datasets) in the report designer. It is not a table name.

Also try to use expression builder to learn more.
If I select the function ISNULL() in the expression builder I get a dialog which defines ISNULL() as ISNULL(Table,Field). Although the definition seems quite clear if I click the elipses button for the first argument (Table) I don't get a list of table names, I get another expression builder dialog which has a 'Database fields' button and if I click that the list of fields displayed is referenced by the DataSet name. It may be better to hide the elipses buttons on this dialog as I think they create confusion.
Back to Top View SteveW's Profile Search for other posts by SteveW
 
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 07 June 2007 at 6:58am | IP Logged Quote SteveW

This still gives me an error:
IF(SalesInvoice.UNIT_NUMBER = '', '', SalesInvoice.UNIT_NUMBER + CHR(13) + CHR(10))

as does this:
IF(UNIT_NUMBER = '', '', UNIT_NUMBER + CHR(13) + CHR(10))

but now the displayed error message is just:
"Error:"

SalesInvoice is the name of the DataSet and UNIT_NUMBER is one of the fields.
Back to Top View SteveW's Profile Search for other posts by SteveW
 
administrator
Admin Group
Admin Group
Avatar

Joined: 01 October 2003
Online Status: Offline
Posts: 46
Posted: 07 June 2007 at 7:11am | IP Logged Quote administrator

What type has UNIT_NUMBER field? I've just checked the expression
IF(Dataset1.Descript = '', '', Dataset1.Descript + CHR(13)+chr(10))
on my test report. It's working

Maybe your dataset is closed in the report designer?

__________________
Oleg Yershov
Back to Top View administrator's Profile Search for other posts by administrator Visit administrator's Homepage
 
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 07 June 2007 at 7:40am | IP Logged Quote SteveW

administrator wrote:
What type has UNIT_NUMBER field?
VARCHAR the database is Firebird 2.0

administrator wrote:
I've just checked the expression
IF(Dataset1.Descript = '', '', Dataset1.Descript + CHR(13)+chr(10))
on my test report. It's working

Maybe your dataset is closed in the report designer?
If I select 'Datasets...' from the 'Report' menu and click on the 'View data' button I can see my records so I don't think that's the problem.

The Dataset is based on a Firebird VIEW rather than a TABLE, could that be the problem? Maybe ADO can not determine the field data type.

I will experiment with different SQL statements to see if some work and some don't.
Back to Top View SteveW's Profile Search for other posts by SteveW
 
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 11 June 2007 at 2:54am | IP Logged Quote SteveW

I have tried changing the SQL so I'm only using tables and not views but I still have the same problem.

The dialog says "ERROR:" and nothing more.
Back to Top View SteveW's Profile Search for other posts by SteveW
 
administrator
Admin Group
Admin Group
Avatar

Joined: 01 October 2003
Online Status: Offline
Posts: 46
Posted: 11 June 2007 at 3:08am | IP Logged Quote administrator

What is length of UNIT_NUMBER field?

__________________
Oleg Yershov
Back to Top View administrator's Profile Search for other posts by administrator Visit administrator's Homepage
 
SteveW
Newbie
Newbie


Joined: 05 April 2007
Location: United Kingdom
Online Status: Offline
Posts: 19
Posted: 11 June 2007 at 7:26am | IP Logged Quote SteveW

20
Back to Top View SteveW's Profile Search for other posts by SteveW
 
administrator
Admin Group
Admin Group
Avatar

Joined: 01 October 2003
Online Status: Offline
Posts: 46
Posted: 11 June 2007 at 11:27am | IP Logged Quote administrator

Can you send me your report project and exact description of the table structure?
my address is oleg[at]metamatica.com

__________________
Oleg Yershov
Back to Top View administrator's Profile Search for other posts by administrator Visit administrator's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.91
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.0625 seconds.