Field Properties

mans
09-05-2000, 11:19 PM
Hello,

I am using VB6 with Access2000. I am also using the code below to append a field called "end" to a table called "Table", the code works fine (ignore declarations). Can somebody please let me know what code I can add so I am able to define the field properties which must include whether: a value for the (new) field is required (defaults to No in Access), a zero length is allowed (defaults to No in Access) and if duplicates are allowed (defaults to Yes in Access).

Set td = daoDB36.TableDefs("Table")
Set F = td.CreateField("end", dbText)
td.Fields.Append F

Thank You

karimahta
09-06-2000, 09:48 AM
I haven't got access to Access at the moment, so I may not be 100% accurate but, using yout field object called F...

F.Required = True/False ......for the required property.
F.AllowZeroLength = True/False .....for the zero length property.


The Indexed (duplicates OK) property is not actually a property. It's another way of quickly adding an index in the access environment. (You can also click on the indexes icon on the toolbar and add your field there, you will notice that it's Indexed property is changed also.)

So you need to create a new Index object and append it to the table (after the field).

E.G. Say your field is called Code then it goes something like this:
<CODE>Dim idx as Index

Set idx = New Index
idx.Unique = True
idx.Fields = "Code"
td.Indexes.Append idx</CODE>


HTH

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum