Question: Microsoft Access 2016 I'm facing problems with these two buttons within my code. Any help on figuring out why I'm getting error messages? 1. Private

Microsoft Access 2016
I'm facing problems with these two buttons within my code. Any help on figuring out why I'm getting error messages?
1.
Private Sub btnAdd_Click() 'when we click on button Add there are two options '1. for insert '2. for update If Me.txtName.Tag & "" = "" Then 'this is for insert new 'add data to table Dim db As Database Dim rec As Recordset
Set db = CurrentDb Set rec = db.OpenRecordset("Select * from Contact")
rec.AddNew rec("Contact") = Me.txtName rec("Phone") = Me.txtPhone rec("Email") = Me.txtEmail rec.Update Set rec = Nothing Set db = Nothing Else 'otherwise (Tag of txtName store the id of contact to be modified) rec.Execute "Update contact " & _ " SET Contact=" & Me.txtName & _ ", Phone='" & Me.txtPhone & "'" & _ ", Email='" & Me.txtEmail & "'" & _ " WHERE contact=" & Me.txtName.Tag End If 'update subform Me.Contact_subform.Form.Requery
End Sub
2.
Private Sub btnDelete_Click() 'delete record 'check existing selected record If Not (Me.Contact_subform.Form.Recordset.EOF And Me.Contact_subform.Form.Recordset.BOF) Then 'confirm delete If MsgBox("Are you sure you want to delete?", vbYesNo) = vbYes Then 'delete now CurrentDb.Execute "DELETE FROM contact " & _ "WHERE contact=" & Me.Contact_subform.Form.Recordset.Fields("contact") 'refresh data in list Me.Contact_subform.Form.Requery End If End If End Sub
Project low hart Abumkdd Erirace sub brniai ciiok bCurrentDb Microsoft Visu das c tor Appiczbons Cumple urE Hep Project low hart Abumkdd Erirace sub brniai ciiok bCurrentDb Microsoft Visu das c tor Appiczbons Cumple urE Hep
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
