this is the full code here for a button to add data to 2 different tables the weird thing is that i have another form wih a button wih similar function and it works fine wih the same statment Option Compare Database
Private Sub addbutton_Click()
CurrentDb.Execute "INSERT INTO Clients(F_Name,L_Name,Phone_Number,E-mail,Gender,Date_of_Birth) " & "VALUES(" & Me.textfname & ",'" & Me.textlname & "','" & Me.textpnumber & "','" & Me.textemail & "','" & Me.textgender & "','-" & Me.textdob & "')"
CurrentDb.Execute "INSERT INTO Accounts(F_Name,L_Name,Username,Password,accounttype) " & "VALUES(" & Me.textfname & ",'" & Me.textlname & "','" & Me.textusername & "','" & Me.textpassword & "','" & Me.textaccountype & "')"
clientssubform.Form.Requery
End Sub
First, Password is a reserved word, so use
[Password]
.Second, a date expression must be wrapped in octothorpes:
#2017/04/24#
Also, if you won't use parameters, even though recommended, use a function like this to concatenate your values:
Study the in-line comments for usage.
Try to change this part of code
to this
in both lines