maincomputer
New member
- Local time
- Today, 21:42
- Joined
- Jun 22, 2012
- Messages
- 9
Hi,
I've managed to find the following code to change a field's data type. it isn't running, though. I get a Run-time error for the line "fld.Type = 8".
Any help would be gratefully received!
Function ChangeFieldDataType()
Dim db As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Set db = CurrentDb
For Each tdf In db.TableDefs
If tdf.Name = "Opie copy" Then
For Each fld In tdf.Fields
If fld.Name = "Lab_Rep_Date" Then
fld.Type = 8
Exit Function
End If
Next
End If
Next
End Function
I've managed to find the following code to change a field's data type. it isn't running, though. I get a Run-time error for the line "fld.Type = 8".
Any help would be gratefully received!
Function ChangeFieldDataType()
Dim db As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Set db = CurrentDb
For Each tdf In db.TableDefs
If tdf.Name = "Opie copy" Then
For Each fld In tdf.Fields
If fld.Name = "Lab_Rep_Date" Then
fld.Type = 8
Exit Function
End If
Next
End If
Next
End Function