-
This creates a database file:
[vba]'reference: Microsoft ActiveX Data Objects 2.7 Library
'reference: Microsoft ADO Ext. 2.7 for DLL and Security
Dim moADOconn As adodb.Connection
Sub CreateDatabase()
'-------------------------------------------------------------------------
' Procedure : CreateDatabase Created by Jan Karel Pieterse
' Company : JKP Application Development Services (c) 2006
' Author : Jan Karel Pieterse
' Created : 10-5-2006
' Purpose : Creates a Log Database
'-------------------------------------------------------------------------
Dim oADOXcat As ADOX.catalog
Set oADOXcat = New ADOX.catalog
oADOXcat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=""" & ThisWorkbook.Path & "\Log.mdb"";"
Set oADOXcat = Nothing
End Sub
Sub CreateTable()
'-------------------------------------------------------------------------
' Procedure : CreateTable Created by Jan Karel Pieterse
' Company : JKP Application Development Services (c) 2006
' Author : Jan Karel Pieterse
' Created : 10-5-2006
' Purpose : Creates Table in Log Database
'-------------------------------------------------------------------------
' MyText TEXT(50),
' MyMemo MEMO,
' MyByte BYTE,
' MyInteger INTEGER,
' MyLong LONG,
' MyAutoNumber COUNTER,
' MySingle SINGLE,
' MyDouble DOUBLE,
' MyCurrency CURRENCY,
' MyReplicaID GUID,
' MyDateTime DATETIME,
' MyYesNo YESNO,
' MyOleObject LONGBINARY,
' MyBinary BINARY(50)
Dim sSQL As String
OpenDatabase
sSQL = "CREATE TABLE tblLogResults " & _
"(ctrIndex COUNTER, DateAndTime DATETIME, CurrentStage TEXT(255), " & _
"CurrentAction TEXT(255), WorkBook TEXT(255), ObjectType TEXT(255), " & _
"Description TEXT(255), Value1 LONG)"
With moADOconn
.Execute sSQL
End With
End Sub
Sub OpenDatabase()
'-------------------------------------------------------------------------
' Procedure : OpenDatabase Created by Jan Karel Pieterse
' Company : JKP Application Development Services (c) 2006
' Author : Jan Karel Pieterse
' Created : 10-5-2006
' Purpose : Opens Connection to Log Database
'-------------------------------------------------------------------------
If moADOconn Is Nothing Then
Set moADOconn = New adodb.Connection
moADOconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=""" & ThisWorkbook.Path & "\Log.mdb"";"
End If
End Sub[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules