Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create date field in table with function

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
0
0
US
Hi,
I want to add a couple fields to an existing table and change the properties of a current field. I can add the fields but trying to update the properties of the date field I get an error using

fld.Properties("Format").Value = ShortDate

ALso is there an easy way to change the default value of a field already there. I have it set to Now() and want to take that out. This has to be done with code.
Thanks
Lisa
 
Eprice....It's a slippery slope to be on when you start modifying database design on the fly. With that said I'll tell you that there are several ways to do what you describe. You can use SQL; In fact I have scripted entire database builds using SQL. If you just need a quick mod then use the DAO model. Here are a couple of examples. Hope this helps.

'*****Add a field to a table*************
Dim db As DAO.Database
Dim fld As DAO.Field
Dim tdf As DAO.TableDef

Set db = Application.CurrentDb
Set tdf = db.TableDefs("tblTest")
Set fld = tdf.CreateField("sTest", dbText, 25)

tdf.Fields.Append fld

'****Modify a field property******
CurrentDb.TableDefs("tblYourTable").Fields _
("dYourDateField").Properties("DefaultValue")=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top