M
Max Murison
I have been trying to write code to pass perameters to a module that will
add a field to an existing table in a backend database.
All the perameters work apart from the table name. I have tried many
permutations of the table name
I ran this from the Debug window:
CreateTblField "C:\Logbook\Logdat97.mdb", "dbs.TableDefs!Patients",
"EarSize", dbText, 20
Max
This is the code I have used:
Function CreateTblField(strDBName As String, strTblName As String,
strFieldName As String, _
strFieldType As String, strFieldSize As Integer)
On Error GoTo Err_CreateTblField
Dim dbs As Database, tdf As TableDef, tdfTemp As String
Dim fldInitial As Field
Set dbs = DBEngine.OpenDatabase(strDBName)
Set tdf = "dbs.TableDefs!" & strTblName
' Create new Field object.
Set fldInitial = tdf.CreateField(strFieldName, strFieldType,
strFieldSize)
tdf.Fields.Append fldInitial
tdf.Fields.Refresh
Set dbs = Nothing
Thanks.
add a field to an existing table in a backend database.
All the perameters work apart from the table name. I have tried many
permutations of the table name
I ran this from the Debug window:
CreateTblField "C:\Logbook\Logdat97.mdb", "dbs.TableDefs!Patients",
"EarSize", dbText, 20
Max
This is the code I have used:
Function CreateTblField(strDBName As String, strTblName As String,
strFieldName As String, _
strFieldType As String, strFieldSize As Integer)
On Error GoTo Err_CreateTblField
Dim dbs As Database, tdf As TableDef, tdfTemp As String
Dim fldInitial As Field
Set dbs = DBEngine.OpenDatabase(strDBName)
Set tdf = "dbs.TableDefs!" & strTblName
' Create new Field object.
Set fldInitial = tdf.CreateField(strFieldName, strFieldType,
strFieldSize)
tdf.Fields.Append fldInitial
tdf.Fields.Refresh
Set dbs = Nothing
Thanks.