Module Problem (data type)

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
 
First of ll, could you please explain to us why you're needing to change the data type on-the-fly? Looks like a design problem to me.

Also, when you mention "I get a Run-time error", it would be nice to also mention what the error message is exactly.
 
first of ll, could you please explain to us why you're needing to change the data type on-the-fly? Looks like a design problem to me.

Also, when you mention "i get a run-time error", it would be nice to also mention what the error message is exactly.

^^^^^^^ +1 ^^^^^^
 

Users who are viewing this thread

Back
Top Bottom