'Ketik coding berikut pada Module
Option Explicit
Public DbLokasi As String
Public DbNama As String
Public Function CreateDB()
'variabel untuk mendefinisikan database dan tabel
Dim DTB As Database
Dim Tabel As TableDef
Dim Tabel2 As TableDef
Dim Tabel3 As TableDef
Screen.MousePointer = vbHourglass
Set DTB = CreateDatabase(DbLokasi & "\" & DbNama, dbLangGeneral)
Set Tabel = DTB.CreateTableDef("Login")
With Tabel
.Fields.Append .CreateField("UserName", dbText)
.Fields.Append .CreateField("Password", dbText)
End With
Set Tabel2 = DTB.CreateTableDef("Anggota")
With Tabel2
.Fields.Append .CreateField("No", dbText)
.Fields.Append .CreateField("Nama", dbText)
.Fields.Append .CreateField("Alamat", dbText)
.Fields.Append .CreateField("Tanggal", dbDate)
End With
Set Tabel3 = DTB.CreateTableDef("Pekerjaan")
With Tabel3
.Fields.Append .CreateField("Kode", dbInteger)
.Fields.Append .CreateField("Tempat", dbText)
.Fields.Append .CreateField("Golongan", dbText)
End With
DTB.TableDefs.Append Tabel
DTB.TableDefs.Append Tabel2
DTB.TableDefs.Append Tabel3
Set Tabel = Nothing
Set Tabel2 = Nothing
Set Tabel3 = Nothing
DTB.Close
Screen.MousePointer = vbDefault
End Function
Lalu pidah ke form1 letakkan koding berikut kejendela coding form1
'Ketik Coding berikut pada Form
Private Sub Form_Load()
DbLokasi = App.Path
DbNama = "UjexsBase.mdb"
If Dir(DbLokasi & "\" & DbNama) <> "" Then
Kill DbLokasi & "\" & DbNama
End If
Call CreateDB
End Sub
Kemudian simpan project lalu run program, lihat pada folder tempat anda menyimpan project sudah ada file baru dengan nama “UjexsBase.mdb”
Mudah2an ada manfaat nya bagi anda … terimakasih