Bir incele kodları.Referenceden Microsoft.scripting.runtime yi işaretle
Function alanAdlar() As Dictionary
Dim rs As DAO.Recordset
Dim n As Long
Dim scr As New Scripting.Dictionary
Set rs = CurrentDb.OpenRecordset("Tablo1")
With rs
For n = 0 To .Fields.Count - 1
scr(.Fields(n).name) = scr(.Fields(n).name)
Next 'n
.Close
End With
Set alanAdlar = scr
Set rs = Nothing
End Function
Sub test()
Dim rs As DAO.Recordset
Dim n As Long
Const strSQLCreateFoo_c As String = _
"CREATE TABLE Foo" & _
"(" & _
"MyField1 INTEGER," & _
"MyField2 Text(10)" & _
");"
Set rs = CurrentDb.OpenRecordset("Foo")
If Not TableExists("foo") Then
CurrentDb.Execute strSQLCreateFoo_c
End If
For n = 0 To CurrentDb.OpenRecordset("Foo").Fields.Count - 1
For Each xx In alanAdlar.Keys
If rs.Fields(n).name = xx Then
MsgBox "Bulunan Tablo ad: " & rs.Fields(n).name
End If
Next
Next
rs.Close
Set rs = Nothing
' CurrentDb.Execute strSQLAppendBs_c
End Sub
Private Function TableExists(ByVal name As String) As Boolean
On Error Resume Next
TableExists = LenB(CurrentDb.TableDefs(name).name)
End Function