在"myform" 窗体内用命令按钮执行 DoCmd.OpenQuery "查询1" 运行成功。查询1的SQL 代码如下:
INSERT INTO 表1 ( Mobile, Content ) SELECT 表2.电话号码,
([forms]![myform]![text0]) AS 表达式1 FROM表2 WHERE (((表2.学员ID) Like "*" & [forms]![myform]![学员学号] & "*") AND ((表2.姓名) Like "*" & [forms]![myform]![学员姓名] & "*") AND ((表2.学员班) Like "*" & [forms]![myform]![班名] & "*") AND ((表2.学籍) Like "*" & [forms]![myform]![注册] & "*")); 注:text0是myform 窗体上的文本框,输入文本型内容; 现在我不想保留查询1 改在代码里运行如下: CurrentDb.Execute " INSERT INTO表1 ( Mobile, Content ) SELECT " & 表2.电话号码 & " , " & Me.Text0 & " from 表2 WHERE (((表2.学员ID) Like "*" & [forms]![myform]![学员学号] & "*") AND ((表2.姓名) Like "*" & [forms]![myform]![学员姓名] & "*") AND ((表2.学员班) Like "*" & [forms]![myform]![班名] & "*") AND ((表2.学籍) Like "*" & [forms]![myform]![注册] & "*"));
错误提示:“要求对象“,好像是“电话号码” 和“text0” 两边的那些符号不对。请各位老师和版友给看看怎样改? 另外,我想请教:减少查询,该在代码里运行是否效率和可靠性更好? |