(05/03/2020, 13:47)ozanakkaya yazdı: Merhaba, accessde, tablodaki alan adlarında noktalama işareti kullanamazsınız. Accesse veriyi Vba kodları ile tablodaki sırası veya alan adını belirterek almalısın.Öncelikle teşekkürler Ozan bey.. Peki şöyle yapabilmem mümkünmüdür? Mesela Access database dosyam crystal.mbd ve Sayfa1 tablosu var.. Alacağım dosyada donemoncesi.xlsx ve Sayfa1 ya da herhangi bir sayfa... Bu verilerin hepsini alıp crystal.mdb de bulunan Sayfa1 database'ine eklemesi mümkünmüdür?
Dim lngColumn As Long
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnEXCEL As Boolean
blnEXCEL = False
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlx = CreateObject("Excel.Application")
blnEXCEL = True
End If
Err.Clear
On Error GoTo 0
xlx.Visible = True
Set xlw = xlx.Workbooks.Open(CurrentProject.Path & "\exceldokuman.xlsx", , True)
Set xls = xlw.Worksheets("Sayfa1")
Set xlc = xls.Range("A2")
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tbl_tablo1", dbOpenDynaset, dbAppendOnly)
On Error Resume Next
Do While xlc.Value <> ""
rst.AddNew
For lngColumn = 0 To rst.Fields.Count
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
Next lngColumn
rst.Update
Set xlc = xlc.Offset(1, 0)
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
If blnEXCEL = True Then xlx.Quit
Set xlx = Nothing
Üstteki kod, Access uygulamanızla aynı dizindeki exceldokuman.xlsx isimli Excel belgesinin Sayfa1 sayfasındaki verileri, tbl_tablo1 isimli tabloya aktarır.
Dosyaları Alt Alta Birleştirme
Konuyu Okuyanlar: 2 Ziyaretçi