Fix a VBA Function Call with Multiple Arguments in Microsoft Access
Question details
The user needs to call an Access VBA function with two arguments without a syntax error.

- Product
- Microsoft Access VBA
- Device & OS
- not provided
- Scenario
- Calling FunPortalPath with a report PDF name and a grower value.
- Observed behavior
- The parenthesized function call produces a syntax error when used as a standalone statement.
Open the Access database and press Alt+F11 to view the VBA code. Find the FunPortalPath declaration and check its return type and the types and order of its parameters.
Assign the function's return value to a variable
Use this approach when you need the path returned by FunPortalPath.
In the calling procedure in the VBA editor, declare a variable that matches the function's return type. For a String return type, enter: Dim result As String.
Replace the standalone call with: result = FunPortalPath(stRptPDFName, stPortalGrower). Use the returned value in the rest of your procedure as needed.
In the FunPortalPath function, make sure the result is assigned to the function name, for example: FunPortalPath = calculatedPath.
In the VBA editor, select Debug > Compile and correct any highlighted errors, including undeclared variables or mismatched argument types.
Test the function and inspect its arguments
Use the Immediate window and debugger to investigate errors that remain after correcting the call syntax.
Use WPS Office for Everyday Documents and Spreadsheets
WPS Office is a free, lightweight alternative for common office tasks, with a familiar interface and support for Microsoft Office formats that helps make switching easier. It does not fix Access VBA errors or replace an Access database.

Frequently Asked Questions
Why does the function call produce a syntax error?
In a standalone VBA statement, a parenthesized argument list requires the Call keyword. To use the result, write result = FunPortalPath(stRptPDFName, stPortalGrower); to discard it, use Call FunPortalPath(stRptPDFName, stPortalGrower) or omit both Call and the parentheses.
How do I test FunPortalPath without running the whole procedure?
In the VBA editor, select View > Immediate Window and enter ? FunPortalPath("report.pdf", "grower"), using literal values that match the function's parameter types.
What should I check if the call still fails?
Select Debug > Compile to find declaration and type errors. Check the function's parameter order and types, and verify that arguments are not Null when the receiving parameters cannot accept Null.
How does an Access VBA function return a value?
Inside the function, assign the value to the function's name, such as FunPortalPath = calculatedPath. The caller can then store it with result = FunPortalPath(stRptPDFName, stPortalGrower).




