问题
I have a form which lets you add names to the table and shows it in a dropdown menu. When I click on the form, it should ask the user to enter the name they would like to add and click "ok". Once the user clicks ok, the name should be stored in a table and added to the drop-down menu.
Every thing works fine but when the user types the value in the textbox and clicks "ok" a window pops up asking for the parameter value. Whatever the user types in this parameter value gets saved in the table instead of getting the value from the textbox. I am not sure why this happens.
Name is a string, is it the quatation marks?
Here is the code:
Dim test As String
test = Text1.Value
DoCmd.RunSQL "INSERT INTO List_Of_Agencies(T_PI_GroupName)VALUES (" & test & ");"
Form_0_Cover.Combo2.Requery
回答1:
DoCmd.RunSQL "INSERT INTO List_Of_Agencies(T_PI_GroupName) VALUES ('" & test & "')"
来源:https://stackoverflow.com/questions/11210605/why-does-this-sql-statement-ask-for-a-value