Cannot use custom enumeration as a function parameter

I cannot get my custom enumeration values to appear as a drop-down list when trying to pass one of them to another function.  The enumeration and function are in a standard module, and the function call is in a form control.

Here is the enum:
Public Enum FileTypes
    fdtAll = 1
    fdtExcel = 2
    fdtText = 3
End Enum

Open in new window


Here is my function call:
strSelectedFileFullPath = fncFD_GetFileName(strInitialFolder, fdtExcel, fdtAll, , "Select the EDI transaction folder")

Open in new window


And here is the function:
Public Function fncFD_GetFileName(parmInitialFileName As String, _
                parmFilter1 As Long, _
                Optional parmFilter2 As Long, _
                Optional parmFilter3 As Long, _
                Optional parmBoxTitle As String, _
                Optional parmView As MsoFileDialogView = msoFileDialogViewDetails) As String

Open in new window


I also tried it this way:
Public Function fncFD_GetFileName(parmInitialFileName As String, _
                parmFilter1 As Long, _
                Optional parmFilter2 As FileTypes, _
                Optional parmFilter3 As FileTypes, _
                Optional parmBoxTitle As FileTypes, _
                Optional parmView As MsoFileDialogView = msoFileDialogViewDetails) As String

Open in new window

LVL 2
Alan VargaAccess DeveloperAsked:
Who is Participating?
 
Alan VargaConnect With a Mentor Access DeveloperAuthor Commented:
I found my own answer by experimenting.  The parameter in the function call has to be FileTypes.ftdExcel.  Using the enum name followed by a dot displays the desired value selections.  This question can be closed or cancelled.
0
 
Alan VargaAccess DeveloperAuthor Commented:
Please cancel this question, unless leaving it for reference.
0
 
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
No, you don't need the FileTypes first. Your second attempt was close, but I believe you messed up the data types of parmFilter1 and parmBoxTitle (corrected below):
Public Function fncFD_GetFileName(parmInitialFileName As String, _
                parmFilter1 As FileTypes, _
                Optional parmFilter2 As FileTypes, _
                Optional parmFilter3 As FileTypes, _
                Optional parmBoxTitle As String, _
                Optional parmView As MsoFileDialogView = msoFileDialogViewDetails) As String

Open in new window

1
 
Alan VargaAccess DeveloperAuthor Commented:
Thanks Anders, you're right.  I actually did correct the code after I posted here, but didn't retest after making that change.  I just retested, and the class name is not needed.  I appreciate your help!

Alan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.