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

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

问题描述

我有一个表格,可以让您向表格中添加名称并在下拉菜单中显示它.当我单击表单时,它应该要求用户输入他们想要添加的名称,然后单击确定".用户点击确定后,该名称应存储在表格中并添加到下拉菜单中.

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?

代码如下:

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天全站免登陆