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.

HTH,
Nikos

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

End_SetDescription:
  Exit Sub

Err_Property:
' 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
  Else
      MsgBox "Error " & Err.Number & " (" & _
          Err.Description & ")"
      Resume End_SetDescription
  End If
End Sub



.



Relevant Pages

  • Re: Search form with multiple controls
    ... Database is an object in the DAO object model. ... Access 2000 and 2002 don't set that reference). ... Change the declaration from Dim rst as Recordset to Dim rst as DAO.Recordset ...
    (microsoft.public.access.forms)
  • Re: Switchboard question
    ... Access 2000 and 2002 set a reference to the ADO library. ... Scroll down to you get to Microsoft DAO 3.xx and check it. ... Dim dbs As DAO.Database ... Dim rst As DAO.Recordset ...
    (microsoft.public.access.formscoding)
  • Re: storing SQL result into a VB variable?
    ... as I said earlier you can do this using either ADO or DAO. ... you'll need a reference to the Microsoft ActiveX Data Objects ... Dim rst As DAO.Recordset ... Set rst = db.OpenRecordset("SELECT YourField FROM YourTable WHERE ...
    (microsoft.public.access.modulesdaovba)
  • Re: Database not a recognized data type
    ... DAO was not selected in the Object Library. ... When I use Dim db as Database, ... > Access 2003 does set a reference to the DAO object library. ... > to both the DAO and ADO object libraries. ...
    (microsoft.public.access.formscoding)
  • Re: VBA error calling parameter query
    ... DAO, so your code would work fine there. ... usually have a reference set to ADO as well as to DAO, ... Dim rst As DAO.Recordset ...
    (microsoft.public.access.formscoding)