Ah, So that sort of worked. When I used the following code it ran without error:
Code:
fld.Expression = "[MATERIAL]+1"
But the new field contains "#Num!" in all rows. I'm sure this is because [MATERIAL] contains a number stored as a string.
This is really what I'm trying to do (Changed lines in red):
Code:
Private Sub Command0_Click()
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim fld As DAO.Field2
Dim tempName As String
Dim tempVal As Double
Set db = CurrentDb()
Set td = db.TableDefs("WASTE_INVENTORY")
tempName = [MATERIAL]
Select Case tempName
Case "1187356"
tempVal = 292.8
End Select
Set fld = td.CreateField("CalculatedField", dbInteger)
fld.Expression = tempVal & "+1"
td.Fields.Append fld
End Sub
but this results in the error on the 'tempName = [Material]' line: "Run-Time error '2465': Microsoft Access cant find the field '|1' referred to in your expression"
I also tried to type convert it using 'tempNum = CINT([MATERIAL])', but I get the same error.