Connecting Tech Pros Worldwide Forums | Help | Site Map

Table "Description"

Newbie
 
Join Date: Sep 2006
Posts: 1
#1: Sep 25 '06
If you right click on a table name in the tables window and click on properties you get a dialog box that allows you to add a description of the table. My question is using VBA how do you access that 'description' property??? It's NOT a TableDefs property but it is being stored somewhere... Any Ideas?

Thanks!!!

PEB's Avatar
PEB PEB is offline
Expert
 
Join Date: Aug 2006
Location: Bulgaria
Posts: 1,380
#2: Sep 26 '06

re: Table "Description"


Hi,

You can do it by Create property in Mdb

See this exemples from Northwind they can help you to update te properties!

:)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Sub CreatePropertyX()
  3.  
  4.    Dim dbsNorthwind As Database
  5.    Dim prpLoop As Property
  6.  
  7.    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
  8.  
  9.    ' Set the Archive property to True.
  10.    SetProperty dbsNorthwind, "Archive", True
  11.  
  12.    With dbsNorthwind
  13.       Debug.Print "Properties of " & .Name
  14.  
  15.       ' Enumerate Properties collection of the Northwind 
  16.       ' database.
  17.       For Each prpLoop In .Properties
  18.          If prpLoop <> "" Then Debug.Print "  " & _
  19.             prpLoop.Name & " = " & prpLoop
  20.       Next prpLoop
  21.  
  22.       ' Delete the new property since this is a 
  23.       ' demonstration.
  24.       .Properties.Delete "Archive"
  25.  
  26.       .Close
  27.    End With
  28.  
  29. End Sub
  30.  
  31. Sub SetProperty(dbsTemp As Database, strName As String, _
  32.    booTemp As Boolean)
  33.  
  34.    Dim prpNew As Property
  35.    Dim errLoop As Error
  36.  
  37.    ' Attempt to set the specified property.
  38.    On Error GoTo Err_Property
  39.    dbsTemp.Properties("strName") = booTemp
  40.    On Error GoTo 0
  41.  
  42.    Exit Sub
  43.  
  44. Err_Property:
  45.  
  46.    ' Error 3270 means that the property was not found.
  47.    If DBEngine.Errors(0).Number = 3270 Then
  48.       ' Create property, set its value, and append it to the 
  49.       ' Properties collection.
  50.       Set prpNew = dbsTemp.CreateProperty(strName, _
  51.          dbBoolean, booTemp)
  52.       dbsTemp.Properties.Append prpNew
  53.       Resume Next
  54.    Else
  55.       ' If different error has occurred, display message.
  56.       For Each errLoop In DBEngine.Errors
  57.          MsgBox "Error number: " & errLoop.Number & vbCr & _
  58.             errLoop.Description
  59.       Next errLoop
  60.       End
  61.    End If
  62.  
  63. End Sub
  64.  
Newbie
 
Join Date: Nov 2006
Posts: 2
#3: Nov 23 '06

re: Table "Description"


I tried this and it doesn't work

I get a problem on:

Set prp = tbl.CreateProperty("Description", dbText, strName)

(It's also asking for [DDL] after strName ... what is DDL?
Newbie
 
Join Date: Nov 2006
Posts: 2
#4: Nov 23 '06

re: Table "Description"


I got it:

I simply combined the "Set" and "Append" Statements

(I'm referencing my code, but you should get the gist):

tbl.Properties.Append tbl.CreateProperty("Description", dbText, strName)
Newbie
 
Join Date: Nov 2008
Location: LONDON
Posts: 1
#5: Nov 20 '08

re: Table "Description"


This is very helpful but how can I replace the description of it already exists?
Reply