Thursday, July 13, 2006

Adding User-defined Function Libraries to Crystal Reports

Crystal comes with it's own number of Functions that can be used in formula field objects. While crystal provides a huge number of functions that are useful to developers, there are mechanisms to enhance the product with user defined functions libraries. It comes with the ability to accept new functions you develop to meet your needs.

Both available syntaxes (Crystal syntax and Basic syntax) have a branch with additional functions on the bottom of the middle tree. User-defined functions can be added to the additional functions branch of the tree just like if they were existing crystal reports functions.



Creating a user-defined function library

There are two types of function libraries supported by Crystal. Dynamic link libraries and COM Automation server. These libraries can be written in several languages. Dynamic link libraries are usually written in C and must include those files shipped with Crystal. you can also download these files from Crystal Decisions support site.



How to create a project to write functions?

It's really simple and you don't need to worry about interface definitions. Let's write a small function using Visual Basic.

- Create a ActiveX DLL project in Visual Basic
- Add a function named "DateFormat" to your class module or copy the following code.

Public Function DateFormat(ByVal sDate As String) As String
DateFormat = Format(sDate, "dd/MMM/yyyy")
End Function

- Save the project with a meaningful name. Make sure it starts with "CRUFL". For now let's name it as "CRUFLformat"
- Go to --> Make and compile your project into ActiveX DLL (Which will serve as an automation server for Crystal Reports)
- Copy the CRUFLformat.DLL into a directory(better if Windows or crystal reports directory) and register it using regsvr32 exe.



Using it in Crystal Reports

- Create a new report using a database you prefer.
- Insert a formula field. Formula window must appear with 3 panes.
- In the middle pane, go to the Additional functions branch andd you'll see DateFormat function. use it to format the date in a date field.
- Edit the function (changing the date format) and see the difference

14 comments:

  1. Anonymous3:59 AM

    Oh my goodness! Amazing article dude! Many thanks, However I am encountering problems with
    your RSS. I don't know why I cannot subscribe to it. Is there anybody else having similar RSS issues?
    Anyone that knows the answer can you kindly respond?

    Thanks!!

    Have a look at my homepage drain snake Troon

    ReplyDelete
  2. Anonymous8:03 PM

    I'm really enjoying the design and layout of your site.
    It's a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a
    developer to create your theme? Outstanding work!

    Visit my page - reviews of testosterone boosters

    ReplyDelete
  3. Anonymous1:06 AM

    fantastic points altogether, you simply woon a logo new reader.
    What may you recommend in regards to yur submit that you made some days ago?
    Any sure?

    Feel free to visit my site ... iron force hack tool

    ReplyDelete
  4. Anonymous7:39 AM

    Consult with an asylum attorney and make sure that you have enough
    time left on your visa status to ensure your stay after being denied.
    Injury attorneys are lawyers that actually work to relieve the stress of the hard
    time by recovering compensation for the injury.

    Our teams of experts go into the depth of the accidents that has happened and find out the real cause and even those who are responsible for the accident.


    Take a look at my homepage: louisville accident lawyer

    ReplyDelete
  5. Anonymous8:40 PM

    Appreciation to my father who told me about this website, this web site
    is truly awesome.

    Here is my blog post ... Long Beach local seo marketing

    ReplyDelete
  6. Anonymous12:18 AM

    Whoa!This blog look exactly like my old one!
    It's on a entirely diofferent subject but it has pretty much the same layout and design. Great choice of colors!


    Take a loook at my website :: win powerball for a year ()

    ReplyDelete
  7. Anonymous12:20 AM

    Very good post! We will be linking to this particularly great article on our site.
    Keep up the good writing.

    Feel free to surf to my web site :: healthy lawn Offers

    ReplyDelete
  8. Anonymous1:19 AM

    Pretty! This was an incredibly womderful post.
    Thank you for supplying these details.

    My web-site - Cheap Kitchen

    ReplyDelete
  9. Anonymous1:19 AM

    wonderful issues altogether, you just received a new reader.
    What might you suggest in regards to your submit that you simply
    made some days ago? Any sure?

    Also visit my web blog :: diabetes diet

    ReplyDelete
  10. Anonymous2:21 AM

    Can I simply just say what a relief to discover an individual who really understands what
    they are discussing on the web. You definitely understand how to bring a problem to
    light and make it important. A lot more people ought to read this and understand this side of your story.
    I can't believe you aren't more popular since you certainly possess the gift.


    Also visit my weblog - Prosolution

    ReplyDelete
  11. Anonymous3:21 AM

    Wow, superb blog layout! How long have you been blogging for?

    you made blogging look easy. The overall look of your website is excellent, let alone the content!


    Feel free to surf to my web page; massage envy locations mesa

    ReplyDelete
  12. Anonymous11:21 AM

    This is my first time go to see at here and i am truly pleassant to read everthing at alone place.



    Here is my weblog ... Webseite (www.floripa-productions.com)

    ReplyDelete
  13. Anonymous2:26 PM

    If Ifinally receive the item, Ι don't care tҺe delivering time.

    In return the women ցet a man with much leѕs baggage ' no ex-wives,
    children, oг college tuition bills (other than mаybe their oԝn') '
    and fewer ego ƿroblems. “She explained to me thɑt as a woman gets older thе risks of birth defects аre hiǥҺer.


    Feel free to visit my blog post cougar dating Sites tɦat աork
    (Www.plazoo.com)

    ReplyDelete
  14. Anonymous5:24 AM

    군도 다시보기 군도 다시보기 Dataisgreat.com

    ReplyDelete