BlahBlahBlah
Registered User.
- Local time
 - Today, 18:21
 
- Joined
 - Sep 15, 2011
 
- Messages
 - 17
 
Hi.
I'm getting "Argument not optional" on the highlighted line:
	
	
	
		
I have no other functions named "getTableFieldNames". If I change that line to:
	
	
	
		
the error goes away (is using Set here is correct?) but further along in the execution of the code, anything that uses the return value of that function has an error:
Not really sure what to do...
Thanks.
 I'm getting "Argument not optional" on the highlighted line:
		Code:
	
	
	Private Function getTableFieldNames(tableName As String) As Collection
    Dim fieldNames As Collection
    Dim Rst As Recordset
    Dim f As field
    Dim fieldIdx As Integer
    
    Set fieldNames = New Collection
    Set Rst = CurrentDb.OpenRecordset(tableName)
    fieldIdx = 0
    For Each f In Rst.Fields
        ' Skip first field (ID).
        If fieldIdx <> 0 Then
            fieldNames.Add ("[" & f.Name & "]")
        End If
        fieldIdx = fieldIdx + 1
    Next
    Rst.Close
    
    [COLOR=Red][B]getTableFieldNames = fieldNames[/B][/COLOR]
End Function
	
		Code:
	
	
	[COLOR=Red][B]Set getTableFieldNames = fieldNames[/B][/COLOR]
	Run-time error '450':
Wrong number of arguments or invalid property assignment
Not really sure what to do...
Thanks.
			
				Last edited: