Re: Setting Table Description property with code

Hi again Laura,

It's starting to make sense now. No, you don't need to call anybody. While in the VBA window, go Tools > References; check if a Microsoft DAO reference is present among the ones checked at the top of the list. If not, scroll down to find the appropriate Microsoft DAO X.X Object Library reference and check it. The appropriate reference is DAO 3.51 for A97, DAO 3.6 for A2K or later.


laura reid wrote:
Hello, I'm not a programmer, just a copy and paster ;), and I've found the following code to help me copy a table as a backup, however it copies the description as well and I don't want it to. In researching this site, I found information that says I must set the DAO reference library(?). Is this something I can do or will I need to call my sysadmin over to install something?

So here's the code I'm using...what needs to be tweaked in order for me to change the table description property? Thanks

Option Compare Database

Private Sub Command0_Click()
Dim dest As String

dest = "DCPDS Backup - EOM " & Format(Now - Day(Now), "mmm yy")
DoCmd.CopyObject , dest, acTable, "Current DCPDS"
End Sub

Sub SetDescription(TableName As String, _
  TableDescription As String)

On Error GoTo Err_SetDescription

Dim tdfCurr As DAO.TableDef
Dim prpDesc As DAO.Property

  Set tdfCurr = CurrentDb().TableDefs(TableName)
  tdfCurr.Properties("Description") = TableDescription

  Exit Sub

' Error 3270 means that the property was not found.
  If Err.Number = 3270 Then
  ' Create property, set its value, and append it to the
  ' Properties collection.
      Set prpDesc = tdfCurr.CreateProperty( _
        "Description", dbText, TableDescription)
      tdfCurr.Properties.Append prpNew
      Resume Next
      MsgBox "Error " & Err.Number & " (" & _
          Err.Description & ")"
      Resume End_SetDescription
  End If
End Sub