I am trying to query a table for its field names and then put those names in an array to then fill a combobox with. I have gotten the query to work but I keep getting an error when trying to populate the array.
Here is the code I created:
Code:
Public Function fnGetColumnNames(table_name As String) As Variant
Dim rst As New ADODB.Recordset: rst.Open "select * from " + table_name + " where 1=0", CurrentProject.Connection
Dim aColumnNames As Variant
Dim i As Integer: For i = 0 To rst.Fields.Count - 1
aColumnNames(i) = rst.Fields(i).name
Next i
fnGetColumnNames = aColumnNames
End Function
I keep getting a 'Type Mismatch' error on this line of code:
Code:
aColumnNames(i) = rst.Fields(i).name
It is a variant and it should be accepting string values. What am I doing wrong?