Function Create_NCD_Table()
Dim rsp As Recordset
Dim table_name As String
Set dbs = CurrentDb
Set rsp = CurrentDb.OpenRecordset("SELECT ncd_code FROM ncd_disease WHERE ncd_code<>'' GROUP BY ncd_code")
Do While Not rsp.EOF
ncd_code = rsp.Fields("ncd_code")
table_name = "ncd_" & ncd_code
If TableExists(table_name) Then
CurrentDb.TableDefs.Delete (table_name)
End If
Set TBL = dbs.CreateTableDef(table_name)
Set fld = TBL.CreateField("pcucode", dbText, 15)
TBL.Fields.Append fld
Set fld = TBL.CreateField("pid", dbText, 15)
TBL.Fields.Append fld
Set fld = TBL.CreateField("cid", dbText, 15)
TBL.Fields.Append fld
Set fld = TBL.CreateField("chronic", dbText, 15)
TBL.Fields.Append fld
Set fld = TBL.CreateField("vhid", dbText, 8)
TBL.Fields.Append fld
Set fld = TBL.CreateField("sick_year", dbText, 4)
TBL.Fields.Append fld
Set fld = TBL.CreateField("death_year", dbText, 4)
TBL.Fields.Append fld
Set fld = TBL.CreateField("birth_year", dbText, 4)
TBL.Fields.Append fld
'Set fld = TBL.CreateField("Field3", dbInteger)
'TBL.Fields.Append fld
'Set fld = TBL.CreateField("Field4", dbCurrency)
'TBL.Fields.Append fld
dbs.TableDefs.Append TBL
dbs.TableDefs.Refresh
rsp.MoveNext
Loop
End Function
ไม่มีความคิดเห็น:
แสดงความคิดเห็น