larcheve
October 7th, 1999, 10:27 AM
Hi,
Could you help me on the following question:
I would like to modify a field data type of an already built structure of a table in an Access database.
So far, i can only change the name of the field without any problem. When i try to change the field type, i got
a run-time error 3192 informing me that it is illegal and probably a read only property.
Here is the sample code : (the line that the compiler does'nt like is -> td.Fields(j).Attributes = dbUpdatableField Or dbVariableField)
Set dbmap = DBEngine.Workspaces(0).OpenDatabase("test.mdb")
For intctr = 0 To dbmap.TableDefs.Count - 1
Set td = dbmap.TableDefs(intctr)
If (td.Attributes And dbSystemObject) = 0 Then
List1.AddItem td.Name
List1.AddItem td.Attributes
List1.AddItem td.Updatable
For j = 0 To td.Fields.Count - 1
Set fld = td.Fields(j)
List1.AddItem fld.Name + " " + " " + CStr(fld.Type) + " " + CStr(fld.Attributes)
If fld.Name = "v1" Then
td.Fields(j).Attributes = dbUpdatableField Or dbVariableField
td.Fields.Refresh
fld.Type = 1
End If
Next j
td.Fields.Refresh
End If
Next intctr
dbmap.Close
Here is there a way around ?
bye
Could you help me on the following question:
I would like to modify a field data type of an already built structure of a table in an Access database.
So far, i can only change the name of the field without any problem. When i try to change the field type, i got
a run-time error 3192 informing me that it is illegal and probably a read only property.
Here is the sample code : (the line that the compiler does'nt like is -> td.Fields(j).Attributes = dbUpdatableField Or dbVariableField)
Set dbmap = DBEngine.Workspaces(0).OpenDatabase("test.mdb")
For intctr = 0 To dbmap.TableDefs.Count - 1
Set td = dbmap.TableDefs(intctr)
If (td.Attributes And dbSystemObject) = 0 Then
List1.AddItem td.Name
List1.AddItem td.Attributes
List1.AddItem td.Updatable
For j = 0 To td.Fields.Count - 1
Set fld = td.Fields(j)
List1.AddItem fld.Name + " " + " " + CStr(fld.Type) + " " + CStr(fld.Attributes)
If fld.Name = "v1" Then
td.Fields(j).Attributes = dbUpdatableField Or dbVariableField
td.Fields.Refresh
fld.Type = 1
End If
Next j
td.Fields.Refresh
End If
Next intctr
dbmap.Close
Here is there a way around ?
bye