Hi everyone,
I wrote some VBA Codes but I become errors. :banghead:
When i click delete button:
Im getting here Runtime error '3075'
Syntax error(missing operator) in query expression 'E-Mail = abc@def.com'
When i click add/update button:
Run-time error '3061'
too few parameters. Expected 1.
Hope so, you can help me .
Thanks.
PS: I'm not cutting my code with & _. Im writing until end of the line.
I wrote some VBA Codes but I become errors. :banghead:
Code:
Private Sub btnAdd_Click()
If Me.txtMail.Tag & "" = "" Then
CurrentDb.Execute "INSERT INTO tblEmployees([E-Mail], [Name], [Surname], [Title], [City], [Phone_Number]) VALUES ('" & Me.txtMail & "', '" & Me.txtName & "', '" & Me.txtSurname & "', '" & Me.txtTitle & "', '" & Me.txtCity & "', '" & Me.txtPhone & "')"
Else
CurrentDb.Execute "UPDATE tblEmployees SET [E-Mail] = '" & Me.txtMail & "', [Name] = '" & Me.txtName & "', [Surname] = '" & Me.txtSurname & "', [Title] = '" & Me.txtTitle & "', [City] = '" & Me.txtCity & "', [Phone_Number] = '" & Me.txtPhone & "' WHERE [E-Mail] = Me.txtMail.Tag"
End If
btnClear_Click
SubEmployees.Form.Requery
End Sub
Private Sub btnClear_Click()
Me.txtMail = ""
Me.txtName = ""
Me.txtSurname = ""
Me.txtTitle = ""
Me.txtCity = ""
Me.txtPhone = ""
Me.txtMail.SetFocus
Me.btnEdit.Enabled = True
Me.BtnAdd.Caption = "Add"
Me.txtMail.Tag = ""
End Sub
Private Sub btnDlt_Click()
If Not (Me.SubEmployees.Form.Recordset.EOF And Me.SubEmployees.Form.Recordset.BOF) Then
If MsgBox("Are you sure to delete?", vbYesNo) = vbYes Then
CurrentDb.Execute "DELETE FROM tblEmployees WHERE E-Mail = " & Me.SubEmployees.Form.Recordset.Fields("E-Mail")
Me.SubEmployees.Form.Requery
End If
End If
End Sub
Private Sub btnEdit_Click()
' Check whether ther exists data'
If Not (Me.SubEmployees.Form.Recordset.EOF And Me.SubEmployees.Form.Recordset.BOF) Then
'get data to text box contol'
With Me.SubEmployees.Form.Recordset
Me.txtMail = .Fields("E-Mail")
Me.txtName = .Fields("Name")
Me.txtSurname = .Fields("Surname")
Me.txtTitle = .Fields("Title")
Me.txtCity = .Fields("City")
Me.txtPhone = .Fields("Phone_Number")
Me.txtMail.Tag = .Fields("E-Mail")
Me.BtnAdd.Caption = "Update"
Me.btnEdit.Enabled = False
End With
End If
End Sub
When i click delete button:
Im getting here Runtime error '3075'
Syntax error(missing operator) in query expression 'E-Mail = abc@def.com'
When i click add/update button:
Run-time error '3061'
too few parameters. Expected 1.
Hope so, you can help me .
Thanks.
PS: I'm not cutting my code with & _. Im writing until end of the line.