p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

crystal_reports thread: Formula problem


Message #1 by "Michel Medawar" <mmedawar@t...> on Wed, 19 Dec 2001 23:24:19 +0200
This is a multi-part message in MIME format.



------=_NextPart_000_000A_01C188E4.4886CF40

Content-Type: text/plain;

	charset="windows-1256"

Content-Transfer-Encoding: quoted-printable



Hi to all

It's been about one week i haven't gone through a problem,

too much time... ))



So i'm trying to concatenate 3 fields with the comma seperator,

upon three check box value in my VB form. i wrote the following

code in my formula expression, there's some part wrong, i don't

know where, i would be grateful for your help.



Dim strDesc as string

if {?blnField1Vis}=3D true and {ado.PolChatxt1}<> "" then strDesc 

=3D({ado.PolChatxt1})

if {?blnField2Vis}=3D true and {ado.PolChatxt2}<> "" then

    if strDesc <> "" then strDesc =3D strDesc + ", " + {ado.PolChatxt2}

    if strDesc =3D "" then strDesc =3D {ado.PolChatxt2}

end if

if {?blnField3Vis}=3D true and {ado.PolChatxt3}<> "" then

    if strDesc <> "" then strDesc =3D strDesc + ", " + {ado.PolChatxt3}

    if strDesc =3D "" then strDesc =3D {ado.PolChatxt3}

end if

{@Description} =3D strdesc



I'm not so familiar with the crystal coding because of the few times

i used it.



Thanks in advance

Hope that Santa Clause will visit you soon...



Michel Medawar










Message #2 by Walt Morgan <wmorgan@s...> on Wed, 19 Dec 2001 15:28:30 -0600
Michel,



I can't help you with your formula, but I can suggest that you choose VB

syntax in the formula operation; that way you do not have to become familiar

with another syntax.



Walt





Message #3 by "Trung Than Chieu Le" <chieutrung@h...> on Thu, 20 Dec 2001 13:04:37 +0700
Hello Michel,



I think sometime the result will return a Null value because one of fields 

in ado is Null.



Please use this code as follow (with Basic sytax in CR):



Dim strPol1 as String, strPol2 as String, strPol3 as String

Const cstrSeperator As String=", "

strPol1=Trim({ado.PolChatxt1}) & cstrSeperator

strPol2=Trim({ado.PolChatxt2}) & cstrSeperator

strPol3=Trim({ado.PolChatxt3})

If {?blnField1Vis}= true And ((Not IsNull(strPol1)) or strPol1 <> 

cstrSeperator) Then formula=strPol1

If {?blnField2Vis}= true And ((Not IsNull(strPol2)) or strPol2 <> 

cstrSeperator) Then formula=formula & strPol2

If ({?blnField3Vis}= true) And ((Not IsNull(strPol3)) or strPol3 <> "") Then 

formula=formula & strPol3

' Use formula var instead of {@Description}



Good luck!



Chieu Trung



>From: "Michel Medawar" <mmedawar@t...>

>Reply-To: "crystal_reports" <crystal_reports@p...>

>To: "crystal_reports" <crystal_reports@p...>

>Subject: [crystal_reports] Formula problem

>Date: Wed, 19 Dec 2001 23:24:19 +0200

>

>Hi to all

>It's been about one week i haven't gone through a problem,

>too much time... ))

>

>So i'm trying to concatenate 3 fields with the comma seperator,

>upon three check box value in my VB form. i wrote the following

>code in my formula expression, there's some part wrong, i don't

>know where, i would be grateful for your help.

>

>Dim strDesc as string

>if {?blnField1Vis}= true and {ado.PolChatxt1}<> "" then strDesc 

>=({ado.PolChatxt1})

>if {?blnField2Vis}= true and {ado.PolChatxt2}<> "" then

>     if strDesc <> "" then strDesc = strDesc + ", " + {ado.PolChatxt2}

>     if strDesc = "" then strDesc = {ado.PolChatxt2}

>end if

>if {?blnField3Vis}= true and {ado.PolChatxt3}<> "" then

>     if strDesc <> "" then strDesc = strDesc + ", " + {ado.PolChatxt3}

>     if strDesc = "" then strDesc = {ado.PolChatxt3}

>end if

>{@Description} = strdesc

>

>I'm not so familiar with the crystal coding because of the few times

>i used it.

>

>Thanks in advance

>Hope that Santa Clause will visit you soon...

>

>Michel Medawar

>

>

>

>




>$subst('Email.Unsub').





_________________________________________________________________

Send and receive Hotmail on your mobile device: http://mobile.msn.com



Message #4 by "Michel Medawar" <mmedawar@t...> on Fri, 21 Dec 2001 00:09:55 +0200
Hi Chieu Trung



Well i used the same code you wrote,

and it's still giving me that message "there

is an error in that formula" and "a statement

is expected here".



Regards



Michel Medawar





----- Original Message -----

From: "Trung Than Chieu Le" <chieutrung@h...>

To: "crystal_reports" <crystal_reports@p...>

Sent: Thursday, December 20, 2001 8:04 AM

Subject: [crystal_reports] Re: Formula problem





> Hello Michel,

>

> I think sometime the result will return a Null value because one of fields

> in ado is Null.

>

> Please use this code as follow (with Basic sytax in CR):

>

> Dim strPol1 as String, strPol2 as String, strPol3 as String

> Const cstrSeperator As String=", "

> strPol1=Trim({ado.PolChatxt1}) & cstrSeperator

> strPol2=Trim({ado.PolChatxt2}) & cstrSeperator

> strPol3=Trim({ado.PolChatxt3})

> If {?blnField1Vis}= true And ((Not IsNull(strPol1)) or strPol1 <>

> cstrSeperator) Then formula=strPol1

> If {?blnField2Vis}= true And ((Not IsNull(strPol2)) or strPol2 <>

> cstrSeperator) Then formula=formula & strPol2

> If ({?blnField3Vis}= true) And ((Not IsNull(strPol3)) or strPol3 <> "")

Then

> formula=formula & strPol3

> ' Use formula var instead of {@Description}

>

> Good luck!

>

> Chieu Trung

>

> >From: "Michel Medawar" <mmedawar@t...>

> >Reply-To: "crystal_reports" <crystal_reports@p...>

> >To: "crystal_reports" <crystal_reports@p...>

> >Subject: [crystal_reports] Formula problem

> >Date: Wed, 19 Dec 2001 23:24:19 +0200

> >

> >Hi to all

> >It's been about one week i haven't gone through a problem,

> >too much time... ))

> >

> >So i'm trying to concatenate 3 fields with the comma seperator,

> >upon three check box value in my VB form. i wrote the following

> >code in my formula expression, there's some part wrong, i don't

> >know where, i would be grateful for your help.

> >

> >Dim strDesc as string

> >if {?blnField1Vis}= true and {ado.PolChatxt1}<> "" then strDesc

> >=({ado.PolChatxt1})

> >if {?blnField2Vis}= true and {ado.PolChatxt2}<> "" then

> >     if strDesc <> "" then strDesc = strDesc + ", " + {ado.PolChatxt2}

> >     if strDesc = "" then strDesc = {ado.PolChatxt2}

> >end if

> >if {?blnField3Vis}= true and {ado.PolChatxt3}<> "" then

> >     if strDesc <> "" then strDesc = strDesc + ", " + {ado.PolChatxt3}

> >     if strDesc = "" then strDesc = {ado.PolChatxt3}

> >end if

> >{@Description} = strdesc

> >

> >I'm not so familiar with the crystal coding because of the few times

> >i used it.

> >

> >Thanks in advance

> >Hope that Santa Clause will visit you soon...

> >

> >Michel Medawar

> >

> >

> >

> >




> >$subst('Email.Unsub').

>

>

> _________________________________________________________________

> Send and receive Hotmail on your mobile device: http://mobile.msn.com

>

>




$subst('Email.Unsub').

>








  Return to Index