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

Page 1 of 1

## 2 Replies - 13024 Views - Last Post: 03 June 2010 - 07:25 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=176159&amp;s=7b21df12780a4d164090492f7a22aa75&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 rlalande

• New D.I.C Head

Reputation: 0
• 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

• This space intentionally left blank

Reputation: 1726
• Posts: 5,696
• 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

### #3 rlalande

• New D.I.C Head

Reputation: 0
• 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