raleglover
Jul 18th, 2000, 11:03 PM
There must be a way, but I have yet to find it. Need to set several field properties at run time (vb6). This approach generates errors (in most cases) and I can find no other. Is it possibe (since allowzerolength and defaultvalue do work) or am I missing something basic. Code sample below.
dim db as database
dim tb as tabedef
dim f1 as field 'source field
dim f2 as field 'destination field
dim x as integer
dim y as integer
dim z as variant
dim w as integer
dim q as integer
set db = opendatabase("mydatabase.mdb")
Set tb = db.TableDefs("Test Table")
'get first field's properties
Set f1 = tb.Fields("field1")
x = f1.Type
y = f1.Size
z = f1.DefaultValue
w = f1.Attributes
q = f1.AllowZeroLength
'attempt to make 2nd field look like first field
Set f2 = tb.Fields("field2")
f2.Type = x 'errors
f2.Size = 50 'errors
f2.DefaultValue = z 'works
f2.Attributes = w 'errors
f2.AllowZeroLength = q 'works
Maybe these properties (noted with errors) can't be changed at run-time in this manner. Is there another way?
Randy
dim db as database
dim tb as tabedef
dim f1 as field 'source field
dim f2 as field 'destination field
dim x as integer
dim y as integer
dim z as variant
dim w as integer
dim q as integer
set db = opendatabase("mydatabase.mdb")
Set tb = db.TableDefs("Test Table")
'get first field's properties
Set f1 = tb.Fields("field1")
x = f1.Type
y = f1.Size
z = f1.DefaultValue
w = f1.Attributes
q = f1.AllowZeroLength
'attempt to make 2nd field look like first field
Set f2 = tb.Fields("field2")
f2.Type = x 'errors
f2.Size = 50 'errors
f2.DefaultValue = z 'works
f2.Attributes = w 'errors
f2.AllowZeroLength = q 'works
Maybe these properties (noted with errors) can't be changed at run-time in this manner. Is there another way?
Randy