为什么这个SQL语句请求一个值? [英] Why does this SQL statement ask for a value?

查看:373
本文介绍了为什么这个SQL语句请求一个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,它可以让你添加名称表并显示在一个下拉菜单。 当我点击的形式,就应该要求用户输入自己想加,然后单击确定按钮的名称。一旦用户点击OK,名称应存储在一个表中,并加入到下拉菜单

每一件事情工作正常,但是当用户键入的文本框中的值并单击确定按钮弹出一个窗口要求输入参数值。无论用户在该参数值获取保存得到的文本框中的值的表来代替。我不知道为什么会这样。

名称是一个字符串,就是它的quatation马克?

下面是code:

 昏暗测试作为字符串
测试= Text1.Value
DoCmd.RunSQLINSERT INTO List_Of_Agencies(T_PI_GroupName)VALUES(&放大器;测试和安培;);
Form_0_Cover.Combo2.Requery
 

解决方案

  DoCmd.RunSQLINSERT INTO List_Of_Agencies(T_PI_GroupName)VALUES('&放大器;测试及放大器;')
 

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

解决方案

DoCmd.RunSQL "INSERT INTO List_Of_Agencies(T_PI_GroupName) VALUES ('" & test & "')"

这篇关于为什么这个SQL语句请求一个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆