VBA/Excel/Access/Word/Access/CurrentProject Connection — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:46, 26 мая 2010
Connecting with Microsoft Access with ADODB.Connection
Sub openForm()
Dim con As ADODB.Connection
Set con = CurrentProject.Connection
End Sub
Establishing a Connection to the Current Access Database
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