DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   initial value (http://www.daniweb.com/forums/thread201729.html)

shiv0013 Jul 5th, 2009 1:10 am
initial value
 
what will be the initial value of the fields created in a new table(dao)?
how to change it?

vb5prgrmr Jul 5th, 2009 8:01 am
Re: initial value
 
That all depends upon if you allow those fields to default to their default values or not. As for changing those default values lets see your table creation code...

shiv0013 Jul 5th, 2009 9:29 am
Re: initial value
 
Set login = OpenDatabase("database path")
Set newtable = login.CreateTableDef("table_name")
With newtable
.Fields.Append .CreateField("name", dbText, 30)
end with
now wat is the default initial value and how can i change it?

vb5prgrmr Jul 6th, 2009 1:05 am
Re: initial value
 
Okay, this example works with both 2.5/3.51 and 3.6...
Dim daoDb As DAO.Database
Dim daoTd As DAO.TableDef

Set daoDb = DBEngine.CreateDatabase("C:\z\MyDB.mdb", dbLangGeneral, dbVersion30)

Set daoTd = daoDb.CreateTableDef("MyTable")

daoTd.Fields.Append daoTd.CreateField("iID", dbLong)
daoTd.Fields("iID").Attributes = dbAutoIncrField

daoTd.Fields.Append daoTd.CreateField("vFName", dbText, 30)
daoTd.Fields("vFName").AllowZeroLength = True
daoTd.Fields("vFName").DefaultValue = "Enter First Name Here"

daoDb.TableDefs.Append daoTd

Set daoTd = Nothing
daoDb.Close
Set daoTd = Nothing


Good Luck


All times are GMT -4. The time now is 3:30 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC