I use this to list table fieldnames to the debug window.
Can it be modified to perform similar objective for saved
query objects? Would it be best to trash this completely
and write a procedure for queries from scratch?
Private Sub ListFieldsBttn_Click()
'*********************************************
' Prompt user for the table name. List the
' [FieldName]s in the immediate window.
'*********************************************
Dim MyDB As Database, MyData As Recordset
Dim TempRecordset As Recordset, i As Integer
Dim j As Integer, Msg As String, Title As String
Dim Defvalue As String, Answer As String
Dim PString As String
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Msg = "Enter table name."
Title = "Table Name?"
Defvalue = "Notes4PHPMySQLprgmmr"
Answer = InputBox$(Msg, Title, Defvalue)
If Answer = "" Then Exit Sub
Set MyData = MyDB.OpenRecordset(Answer, DB_OPEN_SNAPSHOT)
Debug.Print
For j = 0 To MyDB.Recordsets.Count - 1
Set TempRecordset = MyDB.Recordsets(j)
HowManyFields = TempRecordset.Fields.Count
If HowManyFields > 99 Then
PString = "There are " & CStr(HowManyFields)
PString = PString & " fields. Remember, the "
PString = PString & "immediate window will only "
PString = PString & "display 99 lines."
MsgBox PString
End If
Debug.Print
Debug.Print
Debug.Print "Fields in "; TempRecordset.Name & ":"
Debug.Print
For i = 0 To TempRecordset.Fields.Count - 1
Debug.Print TempRecordset.Fields(i).Name
Next i
Next j
MyData.Close
End Sub