excel vba access kayıt

Katılım
30 Ocak 2008
Mesajlar
154
Excel Vers. ve Dili
offis 2003
arkadaslar excelde 1 adet textbox daki veriyi aa.mdb ye kaydetmek için gerekli kod nedir kücük birşey yapıcam kendime kaydetme nin kücük örneğini verebilirmisiniz.
 
Katılım
18 Nisan 2007
Mesajlar
2,053
Excel Vers. ve Dili
Access 2019
Merhaba..

Bütünüyle bir bağlantı ve kayıt prosedürü bu şekildedir..

Kod:
Private adoCN As Object

Private Sub CommandButton1_Click()
'On Error Resume Next
Application.ScreenUpdating = False
'Accesse atar.......................................................................
Set RS = CreateObject("ADODB.recordset")
  strSQL = "SELECT * FROM Tablo1 Where No='" & TextBox1 & "'"
  RS.Open strSQL, adoCN, 3, 3

  If RS.RecordCount = 0 Then
    RS.AddNew
    RS("Adı") = TextBox1
    RS("soyadı") = TextBox2
    RS("telefon") = TextBox3
    RS.Update

  Else
    MsgBox TextBox1 & " adlı kişiyi daha önce girmiştiniz.", , "deneme"
  End If
  RS.Close
  'RefreshDB
  Set kayit = Nothing
End Sub



Private Sub UserForm_Initialize()
On Error Resume Next

  Set adoCN = CreateObject("ADODB.Connection")
  
    DatabasePath = _
        "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
            ThisWorkbook.Path & "\vt1.mdb"
            
    If Dir(ThisWorkbook.Path & "\vt1.mdb") = "" Then
        MsgBox DatabasePath & " bulunamadı, programdan çıkılacak !", vbCritical, "sevk"
        Unload Me
        Exit Sub
    End If
    
    adoCN.ConnectionString = DatabasePath
    adoCN.Open
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
On Error Resume Next
adoCN.Close
Set adoCN = Nothing
End Sub
Kaynak..: forum..
 
Üst