Adam
Adam

Reputation: 1011

MS Access VBA: Optional Argument Does Not Assume Default Value

I imagine this is an easy one. I have the following declarations:

Public Const TABLE_MY_TABLE As String = "my_table"

Sub reloadProjections(startDate As String, endDate As String, _
                      Optional tableName As String = TABLE_MY_TABLE)

   'Processing occurs here

End Sub

For some reason, when the optional argument is not supplied, tableName does not assume the default value of TABLE_MY_TABLE. When you step through this with a debugger, TABLE_MY_TABLE is set to "my_table" and tableName is an empty string. Does anyone know why?

Upvotes: 2

Views: 2359

Answers (1)

Fionnuala
Fionnuala

Reputation: 91346

It works for me. How are you calling it? Try, say:

 reloadProjections date(),date()

Upvotes: 1

Related Questions