A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

DDL statement question ?



 
 
Thread Tools Display Modes
  #1  
Old September 19th, 2008, 07:49 PM posted to microsoft.public.access.tablesdbdesign
luis_a_roman via AccessMonster.com
external usenet poster
 
Posts: 9
Default DDL statement question ?

How can I change the attribute of an element in the date to date format with
a short date format. The ddl statement that I'm trying to debug is below.

Alter Table xMilestones Alter Column Finish_Date date/time(short date)

Help will be appreciated.

Luis

--
Message posted via http://www.accessmonster.com

  #2  
Old September 19th, 2008, 09:01 PM posted to microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default DDL statement question ?

As far as I know, you can't set a field format using DDL. You'd have to use
DAO (or ADOX).

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"luis_a_roman via AccessMonster.com" u41449@uwe wrote in message
news:8a702b1bca5d5@uwe...
How can I change the attribute of an element in the date to date format
with
a short date format. The ddl statement that I'm trying to debug is below.

Alter Table xMilestones Alter Column Finish_Date date/time(short date)

Help will be appreciated.

Luis

--
Message posted via http://www.accessmonster.com



  #3  
Old September 22nd, 2008, 01:07 AM posted to microsoft.public.access.tablesdbdesign
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default DDL statement question ?

Using DAO:

Const PROPEXISTS = 3367
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim prp As DAO.Property
DIM fld AS DAO.Field

Set dbs = CurrentDb
Set tdf = dbs.TableDefs("xMilestones")
With tdf
Set fld = .Fields("Finish_Date")
On Error Resume Next
' attempt to create new property
Set prp = fld.CreateProperty("Format", dbText, "Short date")
Select Case Err
Case 0
' no error so append property
fld.Properties.Append prp
Case PROPEXISTS
' set property value
fld.Properties("Format") = "Short Date"
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select
End With

Unless the column's Format property has already been created its necessary
to do so before its value can be set, so the code attempts to do this first.
This will raise an error if the property already exists, so this is trapped;
its then merely a case of setting the property's value.

With code like this in reality you'd be more likely to wrap it in a function
into which you'd pas the table name, column name, property name, property
type and property value as arguments rather than hard coding them as above.

Ken Sheridan
Stafford, England

"luis_a_roman via AccessMonster.com" wrote:

How can I change the attribute of an element in the date to date format with
a short date format. The ddl statement that I'm trying to debug is below.

Alter Table xMilestones Alter Column Finish_Date date/time(short date)

Help will be appreciated.

Luis

--
Message posted via http://www.accessmonster.com



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.