Private Sub cmdMakeDb_Click()
Dim db_name As String
Dim db As Database
' Get the database name.
db_name = App.Path
If Right$(db_name, 1) <> "\" Then db_name = db_name & _
"\"
db_name = db_name & "test.mdb"
' Delete the database if it exists.
On Error Resume Next
Kill db_name
On Error GoTo 0
' Create the database.
Set db = DBEngine.CreateDatabase( _
db_name, dbLangGeneral)
' Create the table.
db.Execute "CREATE TABLE Dates (TheDate DATE, TheNumber " & _
"INTEGER)"
' Insert records.
db.Execute "INSERT INTO Dates VALUES (#8/20/2002#, 0)"
db.Execute "INSERT INTO Dates VALUES (#8/21/2002#, 1)"
db.Execute "INSERT INTO Dates VALUES (#8/22/2002#, 2)"
db.Execute "INSERT INTO Dates VALUES (#8/23/2002#, 3)"
db.Execute "INSERT INTO Dates VALUES (#8/24/2002#, 4)"
db.Close
Set db = Nothing
MsgBox "Done"
End Sub
|