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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,223,099
Messages
6,170,109
Members
452,302
Latest member
TaMere

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