Results 1 to 15 of 15

Thread: Crystal Reports Formula problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Crystal Reports Formula problem

    I am trying to use crystal reports 8.5. I have created a formula that is not working. It's very simple yet, I still can't get it to work. Below is what the formula looks like:

    VB Code:
    1. If IsNull({tblClientAddr.addAddr2}) Then
    2.    {tblClientAddr.addAddr1}
    3. Else
    4.    Trim({tblClientAddr.addAddr1}) & ", " & Trim({tblClientAddr.addAddr2})

    I keep getting the error message:

    "The result of the selection formula must be a boolean"

    I also stuck the End If statement in at the end but it still gives me that message. What am I doing wrong?

    thanks,
    Blake

  2. #2
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: Crystal Reports Formula problem

    i think there is a special forum for this... anyway can you post the line of code that it is high lighting?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    It's the very beginning of the statement....the cursor sets right in front of the IF.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    Ok,

    Now if I insert the End If at the end of the If statement....I get the following error msg:

    VB Code:
    1. If IsNull({tblClientAddr.addAddr2}) Then
    2.    {tblClientAddr.addAddr1}
    3. Else
    4.    Trim({tblClientAddr.addAddr1}) & ", " & Trim({tblClientAddr.addAddr2})
    5. End If

    "The remaining text does not appear to be part of the formula" and the cursor sets at the end of the else branch.

    Hope that helps!

  5. #5
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: Crystal Reports Formula problem

    is it just me or dont i see anything in this code

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal Reports Formula problem

    I think it needs to be like this.
    VB Code:
    1. If IsNull({tblClientAddr.addAddr2}) = True Then
    2.    {tblClientAddr.addAddr1}
    3. Else
    4.    Trim({tblClientAddr.addAddr1}) & ", " & Trim({tblClientAddr.addAddr2})
    Edit: Its been a while since I used CR, but I also think that maybe it needs to actually return a True or False.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    That didn't work Rob....still gives me the same error msg...

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal Reports Formula problem

    I think I know what your trying to do. You need two textbox controls. One
    bound with just field1 and the other bound with field1 and 2. Then in the
    formatting properties of the two textboxes, add this formula to each. It will
    test for field 2 to be null. If it is it sets the visibility to true or false.
    Toggeling each textbox.

    VB Code:
    1. If IsNull({tblClientAddr.addAddr2}) = True Then
    2.    True
    3. Else
    4.    False
    Then in the other textbox, use this.
    VB Code:
    1. If IsNull({tblClientAddr.addAddr2}) = True Then
    2.    False
    3. Else
    4.    True
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    Rob,

    Actually, I have had this formula working in the past and for some reason it's not working now. Anyway, I will try a few more things....

    Thanks

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Crystal Reports Formula problem

    Take out the if/else/end, and try the first statement. It doesn't look like it is doing anything. Whatever you are trying to do doesn't look right. The else clause just concatenates it.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    I tried using this:

    VB Code:
    1. {tblClientAddr.addAddr1} & ", " & {tblClientAddr.addAddr2}

    and it still gave me the msg:

    "The result of the selection formula must be a boolean"

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal Reports Formula problem

    David, he is trying to show only the addres that is populated in the db. If the
    address has only one field the show just that. If the address has two fields
    then show both.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal Reports Formula problem

    Also, where is this formula under, Suppress? If so Suppress need to return a
    True or a False so it knows how to show the control.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports Formula problem

    Rob,

    the formula is not being suppressed!

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Crystal Reports Formula problem

    Hmm..., how about placing the code in a Formula Field. Then bind that
    formula field to your address textbox?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width