2 Replies - 10008 Views - Last Post: 03 June 2010 - 07:25 AM Rate Topic: -----

#1 rlalande  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-September 09

Crystal Reports - Formula using Custom Function - "Too many arguem

Posted 02 June 2010 - 01:55 PM

I did not see a forum for Crystal Reports but seeing as I am using CR with Visual Studio 2008 I will post here and move the thread if told to. That being said here is my problem.

I created a custom function named formatTime. Here is the code
Function (StringVar strTime, BooleanVar bolInPunch)

    NumberVar I := Len(strTime) - 1;
    StringVar strAMPM := fixAMPM(strTime, strAMPM, bolInPunch);
    StringVar T = Left(strTime, I);

    If bolInPunch Then
        strTime = (IIf(val(Right(T, 2)) >= 46, Val(Left(T, 2)) + 1, val(Left(T, 2)))) & ":" & roundIN(Right(T, 2)) & ":00" & strAMPM
    Else
        strTime = Left(T, 2) & ":" & roundOut(Right(T, 2)) & ":00" & strAMPM;
    
    TimeValue(strTime)



I have a formula that is referencing this function.
//Put the date and time together as one DateTime value.
DateTime({TimeClockData.InDate}, formatTime ({TimeClockData.InTime}, False))



I have also written the custom function and the formula in both Crystal and Basic syntax. Either way, when i go to save the formula an error is raised stating Too many arguments have been given to this formula. For fun I removed an argument and got a message stating there were not enough arguments for the function.

Since the function requires 2 variables passed to it and I am passing 2 variables, I can't see where my mistake is. So any help is greatly appreciated.

This post has been edited by rlalande: 02 June 2010 - 01:56 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Crystal Reports - Formula using Custom Function - "Too many arguem

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,919
  • Joined: 25-September 09

Re: Crystal Reports - Formula using Custom Function - "Too many arguem

Posted 02 June 2010 - 02:54 PM

You didn't give your function a name
Private Function myFunctionName(StringVar strTime, BooleanVar bolInPunch) as somereturntype
Was This Post Helpful? 0
  • +
  • -

#3 rlalande  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-September 09

Re: Crystal Reports - Formula using Custom Function - "Too many arguem

Posted 03 June 2010 - 07:25 AM

Thanks for the reply.

There are 2 things you need to keep in mind.

The first being that what you have mentioned in your post works great if i was coding a control on a form within my app. But this is a Crystal report file and the custom function is store with it.

Secondly, I mentioned that I tried coding the function using both Crystal and Basic Syntax. So I did try the variation of your example that is supported by Crystal. I just don't make the Public/Private declaration, but the results were the same. Too many arguments....

With the Crystal Syntax you don't need to declare the Function name when coding it. The name is created once you right click on Report Custom Functions and select New...

So i am still stuck with a non-working function call
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1