Description Filed

P

piotr

Hi,
Is there any way to change value of 'description' field (column) in ms
access tables using scirpts?
I know you can read it using OpenSchema method of ADO Connetcion object but
that's the only thing you can do.

Piotr B.
 
B

Brendan Reynolds

Use DAO ...

Public Sub ChangeDescrip()

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim prp As DAO.Property

On Error GoTo ErrorHandler
Set db = CurrentDb
Set tdf = db.TableDefs("tblTest")
Set fld = tdf.Fields("TestByte")
fld.Properties("Description") = "New Description"

ExitProcedure:
Exit Sub

ErrorHandler:
If Err.Number = 3270 Then
'Property not found
Set prp = fld.CreateProperty("Description", dbText, "New
Description")
fld.Properties.Append prp
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Resume ExitProcedure

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
P

piotr

Yes, this works fine. Thanks a lot.

Piotr B.

U¿ytkownik "Brendan Reynolds said:
Use DAO ...

Public Sub ChangeDescrip()

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim prp As DAO.Property

On Error GoTo ErrorHandler
Set db = CurrentDb
Set tdf = db.TableDefs("tblTest")
Set fld = tdf.Fields("TestByte")
fld.Properties("Description") = "New Description"

ExitProcedure:
Exit Sub

ErrorHandler:
If Err.Number = 3270 Then
'Property not found
Set prp = fld.CreateProperty("Description", dbText, "New
Description")
fld.Properties.Append prp
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
Resume ExitProcedure

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Top