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")
With myTable
.AddNew
!First = Me.FirstName
!Last = Me.LastName
!Street = Me.StreetAddr
!City = Me.City
!State = Me.StateProv
!Zip = Me.ZipCode
!Priority = Me.Priority
!Email=Me.EmailAddr
!Exhb = Me.ExhibClass
!Phone = Me.HomePhone
!altkphone = Me.BizPhone
.Update
End With
myTable.Close
Exit_cmdSaveCurRecord_Click:
Exit Sub
Err_cmdSaveCurRecord_Click:
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.
|