May 15th, 2013, 09:12 AM
VBA Access Create Calculated Field
I am trying to create a calculated field in access using VBA. I have other code working for regular field types (Text,Number,etc). When it comes to the calculated field, the field is not added to the access table. I think it has something to do with the expression.
Set db = CurrentDb()
'This code works fine and the fields are added to access table
For Each strColumn In strColumns
Set columnName = xlsht.Cells(1, strColumn)
If columnName = "National ID" Then
Set columnName = xlsht.Cells(1, "SSN")
If columnName <> "" Then
Set FieldName = tb1.CreateField(columnName, dbText, 150)
'When I try to add calculated Field, it is not added to table
fd1 = "Decease?"
Set f1 = tb1.CreateField(fd1)
f1.Expression = IIf(IsNull([Dt of Death]), 0, IIf([covg elect] = "T", 0, 1))
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!