A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Revised question about Table Description



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2009, 08:38 PM posted to microsoft.public.access
Gary Brown[_5_]
external usenet poster
 
Posts: 87
Default Revised question about Table Description

Does anyone know how to change the Table Description using VBA?
I can do it manually by right-clicking on a table, selecting 'Properties'
and typing in a description but I'd like to do that via code.
I would like to add a description programatically for documentation purposes

Any help would be greatly appreciated.

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown

  #2  
Old July 2nd, 2009, 08:57 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Revised question about Table Description

"Gary Brown" wrote in message
...
Does anyone know how to change the Table Description using VBA?
I can do it manually by right-clicking on a table, selecting 'Properties'
and typing in a description but I'd like to do that via code.
I would like to add a description programatically for documentation
purposes

Any help would be greatly appreciated.



Here's a simple routine, originally posted by Doug Steele, with some minor
changes I made:

'----- start of code -----
Sub SetTableDescription(TableName As String, Description As String)

' Code posted by Douglas J. Steele 11-July-2008
' Modified by Dirk Goldgar, 2-July-2009

On Error GoTo ErrHandler

Dim db As DAO.Database
Dim tdfTable As DAO.TableDef
Dim prpDesc As DAO.Property

Set db = CurrentDb
db.TableDefs(TableName).Properties("Description") = Description

ExitHe
Set prpDesc = Nothing
Set tdfTable = Nothing
Set db = Nothing
Exit Sub

ErrHandler:
Select Case Err.Number
Case 3270 'Property Not Found
Set tdfTable = db.TableDefs(TableName)
Set prpDesc = tdfTable.CreateProperty( _
"Description", dbText, Description)
tdfTable.Properties.Append prpDesc
Case Else
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End Select
Resume ExitHere

End Sub
'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #3  
Old July 2nd, 2009, 09:16 PM posted to microsoft.public.access
Gary Brown[_5_]
external usenet poster
 
Posts: 87
Default Revised question about Table Description

It's a Beautiful thing!
Thanks SO MUCH!!!
--
Sincerely,
Gary Brown



"Dirk Goldgar" wrote:

"Gary Brown" wrote in message
...
Does anyone know how to change the Table Description using VBA?
I can do it manually by right-clicking on a table, selecting 'Properties'
and typing in a description but I'd like to do that via code.
I would like to add a description programatically for documentation
purposes

Any help would be greatly appreciated.



Here's a simple routine, originally posted by Doug Steele, with some minor
changes I made:

'----- start of code -----
Sub SetTableDescription(TableName As String, Description As String)

' Code posted by Douglas J. Steele 11-July-2008
' Modified by Dirk Goldgar, 2-July-2009

On Error GoTo ErrHandler

Dim db As DAO.Database
Dim tdfTable As DAO.TableDef
Dim prpDesc As DAO.Property

Set db = CurrentDb
db.TableDefs(TableName).Properties("Description") = Description

ExitHe
Set prpDesc = Nothing
Set tdfTable = Nothing
Set db = Nothing
Exit Sub

ErrHandler:
Select Case Err.Number
Case 3270 'Property Not Found
Set tdfTable = db.TableDefs(TableName)
Set prpDesc = tdfTable.CreateProperty( _
"Description", dbText, Description)
tdfTable.Properties.Append prpDesc
Case Else
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
End Select
Resume ExitHere

End Sub
'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.