I have the following script which lists the query name and it's field names.
I also want to list any expressions in the field names but am not sure how to achieve it.
i.e the expression in a field of one query is.
The following script only lists the actual field name
I also want to list any expressions in the field names but am not sure how to achieve it.
i.e the expression in a field of one query is.
Code:
Desc: [PMatCatDesc] & " " & [SMatCatDesc] & " " & [SizeDesc] & " " & [ColDesc] & " " & [SysAbb]
Code:
Public Sub QueryFields()
' Read control source property of all controls in all reports.
' Note.. the debug window may not be big enough to display
' all of the data.
Dim db As Database, doc As Document, ctl As Control
Set db = CurrentDb
Dim intX As Integer
Dim SourceName1 As String
Dim qryfld As DAO.QueryDef
Dim dbCurrent As DAO.Database
Dim rstWarr As DAO.Recordset
'Add Temp Table
'FIELDS WITH SQL'S MUST BE MEMO FIELDS ARE NO DATA WILL SHOWN
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable = acDefault, "zzzTempControlSources"
DoCmd.RunSQL "CREATE TABLE [zzzTempControlSources] ([Primary Key Field] AUTOINCREMENT, [ID] number, [FormName] TEXT, [ControlName] Memo, [FieldDef] Memo)"
DoCmd.SetWarnings True
Set dbCurrent = CurrentDb
Set rstWarr = dbCurrent.OpenRecordset("zzzTempControlSources") ' table name
'=====================================================================
Dim i, j
For i = 0 To db.QueryDefs.Count - 1
For j = 0 To db.QueryDefs(i).Fields.Count - 1
'we are adding a record to our table
rstWarr.AddNew
'we add a value to the 1st field of the table which is named FONID
rstWarr("FormName").Value = db.QueryDefs(i).Name
rstWarr("FieldDef").Value = db.QueryDefs(i).Fields(j).Name
'we now add the data to the table
rstWarr.Update
Next j
Next i
'=====================================================================
'clean up memory
Set dbCurrent = Nothing
Set rstWarr = Nothing
Set db = Nothing
DoCmd.OpenTable "zzzTempControlSources", acViewNormal
End Sub