Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a description to a table created in VB 2

Status
Not open for further replies.

Danyul

Technical User
Jul 5, 2001
36
AU
Hi all,

The main database window in Access allows you to right click on a table in the 'table name' column and add a description in the properties form which then shows up to the right of the table name.

When creating tables in VBA how do I emulate this?

many thanks,


Danyul
 
Hi, Danyul!

Here is function for changing of DB object's description writed by myself:

Public Function ChangeDescription(strObjectName As String, strDescription As String, Optional strContainer As String = "Forms")
'strContainer must be equal "Tables", "Reports", "Modules" etc.
'strContainer default value is "Forms"

On Error GoTo Err_Prp
Dim prp As Property
Dim cnt As Container
Dim doc As Document

For Each cnt In CurrentDb.Containers
If cnt.Name = strContainer Then
For Each doc In cnt.Documents
If doc.Name = strObjectName Then
doc.Properties("Description").Value = strDescription
Exit For
End If
Next doc
Exit For
End If
Next cnt

Exit_Prp:
RefreshDatabaseWindow
Exit Function

Err_Prp:
If Err.Number = 3270 Then
'No property
'Creating of property "Description"

Set prp = doc.CreateProperty("Description", dbText, strDescription)
doc.Properties.Append prp
Else
MsgBox Err.Number & vbLf & Error$
End If
Resume Exit_Prp

End Function


Example for changing of table named Test:
call ChangeDescription("Test", _
"This is a new description of table named Test","Tables")


Aivars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top