G
Guest
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
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