Showing posts with label vba. Show all posts
Showing posts with label vba. Show all posts

Monday, October 28, 2013

Simple Add New ADODB Record to Access Table (VBA) example / einfaches Beispiel Hinzufügen ADODB Record zu Access Tabelle (VBA)

Function AddNewRec(dest As String)

   '? AddNewRec("test")
'newway:
    Dim r As New ADODB.Recordset: r.Open dest, CurrentProject.connection, adOpenDynamic, adLockOptimistic
'Oldway (.Mdb files) - does not work with accdb backend)
    'Dim r As Recordset: Set r = CurrentDb.OpenRecordset(dest)
 
    r.AddNew
    r.Fields("Id") = "1"
    r.Fields("name") = "test"
    r.Update
 
    r.Close

End Function

Thursday, October 10, 2013

VBA Write to Textfile - VBA in Text File schreiben


    Open "log.txt" For Output As 2
    Write #1, "Hallo !"
    Close 2