Public Sub ShowFieldNames()
Dim rst As ADODB.Recordset
Dim lngField As Long
Dim strFields As String
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.Open "SELECT * FROM tblTest WHERE False"
For lngField = 0 To .Fields.Count - 1
If lngField = 0 Then
strFields = .Fields(lngField).Name
Else
strFields = strFields & ", " & .Fields(lngField).Name
End If
Next lngField
.Close
End With
MsgBox strFields
End Sub
Alternatively, you could use the OpenSchema method. The code required would
be more complex. It may be more efficient. But I doubt the difference would
be significant in most situations. If you want to check it out, here's a
link to the on-line documentation ...
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthopenschema.asp