VBA & Macro Problems

Fix a VBA Function Call with Multiple Arguments in Microsoft Access

Muhammad TalhaMuhammad Talha Nov 22, 2026 870 views

Question details

The user needs to call an Access VBA function with two arguments without a syntax error.

Fix a VBA Function Call with Multiple Arguments in Microsoft Access
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.
Before you start

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.

Solution 1Recommended

Assign the function's return value to a variable

Use this approach when you need the path returned by FunPortalPath.

1
Declare a result variable

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.

2
Assign the function result

Replace the standalone call with: result = FunPortalPath(stRptPDFName, stPortalGrower). Use the returned value in the rest of your procedure as needed.

3
Check the function's return assignment

In the FunPortalPath function, make sure the result is assigned to the function name, for example: FunPortalPath = calculatedPath.

4
Compile the project

In the VBA editor, select Debug > Compile and correct any highlighted errors, including undeclared variables or mismatched argument types.

Discarding the return value: If you do not need the return value, VBA also permits FunPortalPath stRptPDFName, stPortalGrower or Call FunPortalPath(stRptPDFName, stPortalGrower). The latter explicitly uses Call with parentheses.
Free Microsoft Office alternative

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.

Edit documents, spreadsheets, and presentations in a familiar interfaceOpen and save common Microsoft Office formats, including DOCX, XLSX, and PPTXUse a lightweight office suite for everyday work alongside AccessContinue troubleshooting Access functions in Microsoft Access while using WPS for other office files
microsoft office alternative - wps office

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).