2

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?

1 Answer 1

1

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

 reloadProjections date(),date()
Sign up to request clarification or add additional context in comments.

2 Comments

Good grief - I feel dumb! :) Yes, it works fine. I was staring at the wrong chuck of code. It was passing the argument (not using the default as I assumed) and I misspelled the argument name, so it was passing an empty string. The joys of a loosely-typed language. Thanks for pointing me in the right direction.
Er, what? Loosely typed? If you have OPTION EXPLICIT turned on, you wouldn't be able to compile code with misspelled variable names. That's remedial Access -- you also use OPTION EXPLICIT in all your modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.