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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|