dilerim işinize yarar
Not: Access ve Excel dosyaları aynı klasörde olmalı ve isimler kodlarda yazılan gibi olmalı dosyaların adı adresi yada diğer ad ve adreste yapılacak değişiklikler kodlara da aktarılmalı
'hy Excel dosyalarını bağlama_____________________________
Dim txtDosyaAdres As String
Dim txtExcelSyf As String
Dim txtTblAd As String
txtExcelSyf = "sayfa1!"
txtTblAd = "not1"
If DCount("Name", "MSysObjects", "Name='" & txtTblAd & "' and type in (1,4,6)") > 0 Then DoCmd.DeleteObject acTable, txtTblAd
txtDosyaAdres = CurrentProject.Path & "\not1.xlsx"
DoCmd.TransferSpreadsheet acLink, 10, txtTblAd, txtDosyaAdres, True, txtExcelSyf '& HcrAralik '"sayfa1!"
txtTblAd = "not2"
If DCount("Name", "MSysObjects", "Name='" & txtTblAd & "' and type in (1,4,6)") > 0 Then DoCmd.DeleteObject acTable, txtTblAd
txtDosyaAdres = CurrentProject.Path & "\not2.xlsx"
DoCmd.TransferSpreadsheet acLink, 10, txtTblAd, txtDosyaAdres, True, txtExcelSyf '& HcrAralik '"sayfa1!
'Excel Bğlama bitti____________________________________
'hy Not tablosuna öğrenci ekleme_______________________
Dim SqlOgr As String
SqlOgr = "INSERT INTO notlar ( Ögrencino ) " & _
"SELECT [Öğrenci Bilgileri].[Öğrenci No] " & _
"FROM [Öğrenci Bilgileri] LEFT JOIN notlar ON [Öğrenci Bilgileri].[Öğrenci No] = notlar.Ögrencino " & _
"WHERE (((notlar.Ögrencino) Is Null))"
CurrentDb.Execute SqlOgr
'Öğrenci Ekleme bitti_____________________________________
'hy Notları notlar tablosuna ekleme
Dim SqlNot As String
SqlNot = "UPDATE (Not1 RIGHT JOIN notlar ON Not1.Ögrencino = notlar.Ögrencino) " & _
"LEFT JOIN Not2 ON notlar.Ögrencino = Not2.Ögrencino " & _
"SET notlar.Not1 = [Not1]![Not1], notlar.Not2 = [Not2]![Not2]"
Debug.Print
CurrentDb.Execute SqlNot
'Notları ekleme bitti
'hy gereksiz tabloları silme____________________________
txtTblAd = "not1"
If DCount("Name", "MSysObjects", "Name='" & txtTblAd & "' and type in (1,4,6)") > 0 Then DoCmd.DeleteObject acTable, txtTblAd
txtTblAd = "not2"
If DCount("Name", "MSysObjects", "Name='" & txtTblAd & "' and type in (1,4,6)") > 0 Then DoCmd.DeleteObject acTable, txtTblAd
If Err.Number = 0 Then MsgBox "hatasız bitti"
bilgilendirme: başlangıçta her adım için bir buton koymuştum ama sonra hepsini tek buton altında topladım
Hepsi butonu diğer 3 butonun yaptığını tek başına yapıyor