Error 5. Function error.

mafhobb

Registered User.
Local time
Today, 09:21
Joined
Feb 28, 2006
Messages
1,249
I have a database that uses a printing function but ocasionally I get: Error 5. Invalid procedure call or invalid argument.

This is the way that I call the function from several subs:

Code:
    Dim DocumentName As String
    Dim DocumentType As String
    Dim RecordID As String
    DocumentName = "rptInvfrm"
    DocumentType = "Document"
    RecordID = Me.CallID
    Call PrintingProcess(DocumentName, DocumentType, RecordID)

This is the function declaration:
Code:
Public Function PrintingProcess(DocumentName As String, DocumentType As String, RecordID As String) As String

If I understand correctly, error 5 signifies that the data that is being sent to call the function is not being recognized by the function declaration, so the error has to be between the lines above. However, I fail to see what could possibly be wrong with this.

Any ideas?

Thanks

mafhobb
 
the data that is being sent to call the function is not being recognized by the function declaration

Well then - what data is actually fed into the function when the thing fails?
 
DocumentName's value is the string "rptInvfrm"
DocumentType's value is the string "Document"
RecordID is a string such as "234" or "100"
 
Did you notice what I actually asked? What is fed into the function WHEN IT FAILS!
 
Well the first two are the DocumentName value mentioned and the DocumentType value mentioned. I do not know the value in RecordID yet as this is an error that happens only ocasionally and so far I did not get anyone who got it to give me its value.

In any case RecordID comes from CallID, which is the key used to open the form to print therefore if RecordID was not a valid string (it is a number between 1 and about 60000) it would mean that CallID would not be valid either and the form where the call sub is would not open.
 
maybe you are using "Reserved" names in your function parameter.
 
I don't see any of the words I use in the reserved word list.
 
Is it possible RecordID is Null? Oh, and I would also switch to Long as the Data Type as it appears to always be NUMERIC.
 
You are not putting much mental effort into this, are you?

Make an error logger (google it) so that you know which actual values caused the error when it errors.

Because that takes a long time, cause the error yourself. In whichever way you can think of - Nulls, negative values, 0, whichever, for the one changing variable that you have as input. And then create a permanent test for that variable, yelling loud and clear "Helllooooooooooo this cannot be 0" or whatever. Presumably the data sucks and is out of range, so ultimately you need to ensure data input is OK too.
 

Users who are viewing this thread

Back
Top Bottom