|
-
May 22nd, 2006, 10:49 PM
#1
Thread Starter
New Member
Field Description ---> VBA read/set ??
Is there any way to programatically read or set the field description in the database design view?
Thanks,
DW
-
May 22nd, 2006, 11:10 PM
#2
Re: Field Description ---> VBA read/set ??
We are talking about Access I assume.
You can read the property Description like so...
VB Code:
'Read:
MsgBox Application.CurrentDb.TableDefs("Table1").Fields(0).Properties("Description").Value = "Testing description props of first field."
'Write:
Application.CurrentDb.TableDefs("Table1").Fields(0).Properties("Description").Value = "Testing field description property write"
Last edited by RobDog888; May 22nd, 2006 at 11:14 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 23rd, 2006, 05:50 AM
#3
Thread Starter
New Member
Re: Field Description ---> VBA read/set ??
Yes, Access.
I have a procedure that fills a table with a list of the tables, and fields in the table to produce a report that summarizes the database (see below). I am running into a <property not found> error for those fields where I haven't filled in a description.
I can't seem to trap and skip the error using an If ... Then. I've tried testing if it is Null and also "". Any suggestions?
VB Code:
Dim db As Database
Dim AllTableDefs As DAO.TableDefs
Dim AllFields As DAO.Fields
Dim rstTableList As DAO.Recordset
Dim qdfTables As DAO.QueryDef
Dim NumRecsTableList As Long
Dim NumFields As Long
Dim qdfDelete As DAO.QueryDef
Dim TCount As Long
Dim strSQLDelete As String
Set db = CurrentDb()
' Set AllTableDefs to definitions of all tables in the database:
Set AllTableDefs = db.TableDefs
Set qdfTables = db.QueryDefs("qTableList")
Set rstTableList = db.OpenRecordset("Tablelist", dbOpenDynaset)
rstTableList.MoveLast
NumRecsTableList = rstTableList.RecordCount
'reset the TableList
If NumRecsTableList > 0 Then
strSQLDelete = "DELETE * from [TableList]"
Set qdfDelete = db.CreateQueryDef("", _
strSQLDelete)
qdfDelete.Execute
End If
' Display names of all tables in database:
For j = 0 To AllTableDefs.Count - 1
If Left(AllTableDefs(j).Name, 1) <> "~" And Left(AllTableDefs(j).Name, 4) <> "MSys" And Left(AllTableDefs(j).Name, 1) <> "_" Then
Set AllFields = AllTableDefs(j).Fields
For k = 0 To AllFields.Count - 1
With rstTableList
.AddNew
!tablename = AllTableDefs(j).Name
!FieldName = AllFields(k).Name
If AllFields(k).Properties("Description").Value = "" Then
Else
Debug.Print AllFields(k).Properties("Description").Value
!Description = AllFields(k).Properties("Description").Value
End If
!TYPE = FieldType(AllFields(k).TYPE)
!length = AllFields(k).Size
!DefaultValue = AllFields(k).DefaultValue
!Position = AllFields(k).OrdinalPosition
.Update
End With
Next
End If
Next
End Sub
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|