pastelrain
Registered User.
- Local time
- Today, 04:15
- Joined
- Jul 12, 2016
- Messages
- 23
Hi,
I am trying to create a new column within an existing table in my db. I know I need to define the external field [PHARM_NAME], but I am new to VBA and am not sure of the syntax for defining it.
I was trying to accomplish this in a query expression, but there are several other criteria and it was saying the expression was too complex.
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("NABP_StarValues_w_County")
Set Fld = TableDef.CreateField("GROUPER_NAME", dbDouble)
Fld.Expression = IIf(Left([PHARM_NAME], 4) = "WALG", "WALGREENS", "")
TableDef.Fields.Append Fld
MsgBox "Added"
End Sub
I am trying to create a new column within an existing table in my db. I know I need to define the external field [PHARM_NAME], but I am new to VBA and am not sure of the syntax for defining it.
I was trying to accomplish this in a query expression, but there are several other criteria and it was saying the expression was too complex.
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("NABP_StarValues_w_County")
Set Fld = TableDef.CreateField("GROUPER_NAME", dbDouble)
Fld.Expression = IIf(Left([PHARM_NAME], 4) = "WALG", "WALGREENS", "")
TableDef.Fields.Append Fld
MsgBox "Added"
End Sub