You cannot add a calculated column with SQL because the calculated field requires an expression and cannot be provided through SQL. Technically calculated field is the base type - int, double, text, etc. Above the base type, this is an expression that helps Access do math / logic.
You can use VBA to create a calculated column.
Public Sub CreateField()
Dim DB As DAO.Database
Dim TableDef As DAO.TableDef
Dim Fld As DAO.Field2
Set DB = CurrentDb()
Set TableDef = DB.TableDefs("Table1")
Set Fld = TableDef.CreateField("field3", dbDouble)
Fld.Expression = "[field1] * [field2]"
TableDef.Fields.Append Fld
MsgBox "Added"
End Sub
As Gordon and Bee Jones mentioned, you can create a view or saved query with the appropriate calculations.
source
share