using DAO, updating the table description

crowegreg

Registered User.
Local time
Today, 12:04
Joined
Feb 28, 2011
Messages
108
Hello, I'm trying to use DAO to update within the table properties, the description. This is what I have so far. I haven't tried to run any of this code.

Function ModifyTablePropertyDescription(strArchiveTable As String, strTableDescription As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Properties


Set db = CurrentDb()

Set tdf = db.TableDefs(strArchivetable)

Set fld = db.TableDefs(strArchiveTable).Properties



Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
End Function
 
Thanks. I have used these, but I can't seem to apply any of these to the table properties description.
 
Would something like this work?

Code:
Sub WriteTableDesc()  ' a Table named Comments - some comments were written by other life forms
      Dim db As DAO.Database
      Dim tdf As TableDef

10    Set db = CurrentDb
20    Set tdf = db.TableDefs("Comments")

30    On Error Resume Next
40    tdf.Properties("Description") = "The Comments table is Linked to another planet"

50    If Err.Number = 3270 Then
60        Set prp = tdf.CreateProperty("Description", _
              dbText, "Please don't ignore this error")
70        tdf.Properties.Append prp
80    End If               
End Sub
 
Yes, I just needed to add a dim statement for prp. Thank you!!
 
Good catch, I didn't use option explicit in my testing.

It would help others if you can post the final code and then mark the thread as [Solved]
Edited: Sorry, it is 7 AM here, I didn't see you already had it Solved. thanks
 
Last edited:
Here's the final code. The variables strArchiveTable & strTableDescription are being passed in the call statement from the originating form.

Sub ModifyTablePropertyDescription(strArchiveTable As String, strTableDescription As String)
Dim db As DAO.Database
Dim tdf As TableDef
Dim prp As DAO.Property

Set db = CurrentDb()

Set tdf = db.TableDefs(strArchiveTable)

On Error Resume Next
tdf.Properties("Description") = strTableDescription

If Err.Number = 3270 Then
Set prp = tdf.CreateProperty("Description", _
dbText, "Please don't ignore this error")
tdf.Properties.Append prp
End If

Set prp = Nothing
Set tdf = Nothing
Set db = Nothing
End Sub


Thanks again for your help!!
 

Users who are viewing this thread

Back
Top Bottom