Inster INTO Table Not Working

AsifShah

Board Regular
Joined
Feb 12, 2021
Messages
71
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hello Evory One ... im new in Access please some on help me on Inster into sql commond .. my code is not working.

my code is
SQL:
Dim strInsert As String

strInsert = "INSERT INTO Users (ID, FirstName, LastName, Password, ConfirmPassword, SecurityQuestion, Designation, Mobile, Answer, Picture)" & _
"values ('" & Me.txtID & "', '" & Me.FirstName & "', '" & Me.LastName & "', '" & Me.Password & "', '" & Me.ConfirmPassword & "', '" & Me.SecurityQuestion & "', '" & Me.Designation & "', '" & Me.Mobile & "', '" & Me.Answer & "', '" & Me.txtPicture & "');"

DoCmd.SetWarnings False
DoCmd.RunSQL strInsert
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You do not say why it is not working? :(

Start getting used to using Debug.Print

Use that on strInsert and that should show you your error.
 
Upvote 0
One thing that might be a problem - I think you might need a space between ")" and "values".
Note that you can combine this part:
SQL:
strInsert = "INSERT INTO Users (ID, FirstName, LastName, Password, ConfirmPassword, SecurityQuestion, Designation, Mobile, Answer, Picture)" & _
"values ('"
to this:
SQL:
strInsert = "INSERT INTO Users (ID, FirstName, LastName, Password, ConfirmPassword, SecurityQuestion, Designation, Mobile, Answer, Picture) values('"
 
Upvote 0
Solution
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,466
Members
453,045
Latest member
Abraxas_X

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top