Access VBA

css navigation by

Write from Recordset

I always struggled with RecordSet. The syntax was bewildering to me. Finally I saw what my friend was doing any became hooked.
Private Sub cmdSaveCurRecord_Click()
On Error GoTo Err_cmdSaveCurRecord_Click

    Dim SQLstring       As String
    Dim myTable         As Recordset
    Set myTable = CurrentDb.OpenRecordset("MailingList")
   '  Set the recordSet
        With myTable
            !First = Me.FirstName   ' Table items
            !Last = Me.LastName
            !Street = Me.StreetAddr
            !City = Me.City
            !State = Me.StateProv
            !Zip = Me.ZipCode
            !Priority = Me.Priority
            !Exhb = Me.ExhibClass
            !Phone = Me.HomePhone
            !altkphone = Me.BizPhone
            .Update         ' Update it
        End With
        myTable.Close       ' Close to release memory

    Exit Sub

    MsgBox Err.Description
    Resume Exit_cmdSaveCurRecord_Click
End Sub

My latest project uses lots of RecordSets to post to tables and SQL to get the data back out.

See the picture below for the dialog in from of this code.


© 2008-2024

Updated:  06/21/2024 07:42
This page added:  09 August 2008