1
ห้อง MS Access / : รบกวนช่วยดู code สำหรับสร้าง link table ให้หน่อยครับ
« เมื่อ: 02 ก.พ. 65 , 15:30:14 »
code คุณ TTT ใช้ได้เลยครับ
Private Sub Command1_Click()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
Set tdf = db.CreateTableDef("department")
tdf.Connect = "ODBC;DRIVER={MySQL ODBC 3.51 Driver};Server=192.168.0.243;Database=dental_stock;UID=sa;PWD=sa1234;Option=3"
tdf.SourceTableName = "department"
db.TableDefs.Delete "department"
db.TableDefs.Append tdf
Set tdf = db.CreateTableDef("vendor")
tdf.Connect = "ODBC;DRIVER={MySQL ODBC 3.51 Driver};Server=192.168.0.243;Database=dental_stock;UID=sa;PWD=sa1234;Option=3"
tdf.SourceTableName = "vendor"
db.TableDefs.Delete "vendor"
db.TableDefs.Append tdf
db.Close: Set db = Nothing
End Sub
Private Sub Command1_Click()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
Set tdf = db.CreateTableDef("department")
tdf.Connect = "ODBC;DRIVER={MySQL ODBC 3.51 Driver};Server=192.168.0.243;Database=dental_stock;UID=sa;PWD=sa1234;Option=3"
tdf.SourceTableName = "department"
db.TableDefs.Delete "department"
db.TableDefs.Append tdf
Set tdf = db.CreateTableDef("vendor")
tdf.Connect = "ODBC;DRIVER={MySQL ODBC 3.51 Driver};Server=192.168.0.243;Database=dental_stock;UID=sa;PWD=sa1234;Option=3"
tdf.SourceTableName = "vendor"
db.TableDefs.Delete "vendor"
db.TableDefs.Append tdf
db.Close: Set db = Nothing
End Sub
โพสต์นี้ได้รับคำขอบคุณจาก: Max