VBA/Excel/Access/Word/Access/CurrentProject Connection — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 19:33, 26 мая 2010
Connecting with Microsoft Access with ADODB.Connection
<source lang="vb">
Sub openForm()
Dim con As ADODB.Connection Set con = CurrentProject.Connection
End Sub
</source>
Establishing a Connection to the Current Access Database
<source lang="vb">
Sub Connect_ToCurrentDb()
Dim conn As ADODB.Connection Dim fs As Object Dim txtfile As Object Dim I As Integer Set conn = CurrentProject.Connection Set fs = CreateObject("Scripting.FileSystemObject") Set txtfile = fs.CreateTextFile("C:\Propfile.txt", True) For I = 0 To conn.Properties.Count - 1 Debug.Print conn.Properties(I).Name & "=" & _ conn.Properties(I).Value txtfile.WriteLine (conn.Properties(I).Name & "=" & _ conn.Properties(I).Value) Next I Debug.Print "Please check results in the " & _ "Immediate window." & vbCrLf _ & "The results have also been written to " _ & "the "C:\Propfile.txt" file." txtfile.Close Set fs = Nothing conn.Close Set conn = Nothing
End Sub
</source>