INSERT INTO STATEMENT ERROR

Currentdb.Execute "INSERT INTO tblRegister(Surname,FirstName,MiddleName,Email)" & _
    " VALUES(" & Me.txtSurname & ",'" & Me.txtFName & "','" & Me.txtMName & "','" & Me.txtEmail & "')"

The code above gives me run time error 3061: Too Few parameter: expected 1

Also, I discovered that when I typed (1) the figure (1) into the surname textbox on my form. It inserts into the table tblRegister without the error. How can I make it insert name (letter) into the surname and not a number? Thanks in advance for the answer
Ukaoha EzeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Try this
Currentdb.Execute "INSERT INTO tblRegister(Surname,FirstName,MiddleName,Email)" & _
    " VALUES('"  & Me.txtSurname & "','" & Me.txtFName & "','" & Me.txtMName & "','" & Me.txtEmail & "')"

Open in new window

0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you should do this in case the user is entering single quote ' in to the text fields for better error handling.

Currentdb.Execute "INSERT INTO tblRegister(Surname,FirstName,MiddleName,Email)" & _
    " VALUES('" & replace(Me.txtSurname,"'","''") & "','" & replace(Me.txtFName,"'","''") & "','" & replace(Me.txtMName,"'","''") & "','" & replace(Me.txtEmail,"'","''") & "')"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ukaoha EzeAuthor Commented:
Thanks so much. It all worked very well. Actually.
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
which comment(s) works for you? you may proceed to close this question.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
please comment before we close this question.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
suggested solutions resolved the issue.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.