从查询中引用表单值 [英] Referencing form value from within a query

查看:71
本文介绍了从查询中引用表单值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这不应该太难,但我不熟悉MS对象模型。


假设我有一个表Purchase_Orders和形式TEMP我用来查找客户的订单。表单有一个名为LastName的文本字段,用于键入新订单,但首先让我们看一下以前的订单。表单上的其他位置是Office Web Components电子表格版本11.0,它将运行查询并显示结果列表。


Spreadsheet对象连接到数据源,测试连接检查好的。查询:


SELECT * FROM Purchase_Orders WHERE

(Purchase_Orders.LastName = Forms!TEMP!LastName)


返回的结果是:


没有给出一个或多个必需参数的值。


这似乎是语法问题,而不是从查询内部正确引用表单字段。如果我反而使用


WHERE LastName =''Smith''


它运作得很好。


有人可以帮助我使用正确的MS对象引用约定吗?

I''m sure this shouldn''t be too difficult, but I lack familiarity with the MS object model.

Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer''s orders. The form has a text field named LastName for typing in new orders, but first let''s look at the previous orders. Elsewhere on the form is a Office Web Components Spreadsheet version 11.0, which will run a query and show the result list.

The Spreadsheet object connects to the data source, and the test connection checks out good. The query :

SELECT * FROM Purchase_Orders WHERE
(Purchase_Orders.LastName=Forms!TEMP!LastName)

The result returned is:

No value given for one or more required parameters.

This seems to be a matter of syntax and not referencing the form field properly from inside the query. If I instead use

WHERE LastName=''Smith''

it works just fine.

Can someone help me out with the proper MS object referencing convention?

推荐答案


我确定这不应该太难,但我不熟悉MS对象模型。


假设我有一个表Purchase_Orders和形式TEMP我用来查找客户的订单。表单有一个名为LastName的文本字段,用于键入新订单,但首先让我们看一下以前的订单。表单上的其他位置是Office Web Components电子表格版本11.0,它将运行查询并显示结果列表。


Spreadsheet对象连接到数据源,测试连接检查好的。查询:


SELECT * FROM Purchase_Orders WHERE

(Purchase_Orders.LastName = Forms!TEMP!LastName)


返回的结果是:


没有给出一个或多个必需参数的值。


这似乎是语法问题,而不是从查询内部正确引用表单字段。如果我反而使用


WHERE LastName =''Smith''


它运作得很好。


有人可以帮助我使用正确的MS对象引用约定吗?
I''m sure this shouldn''t be too difficult, but I lack familiarity with the MS object model.

Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer''s orders. The form has a text field named LastName for typing in new orders, but first let''s look at the previous orders. Elsewhere on the form is a Office Web Components Spreadsheet version 11.0, which will run a query and show the result list.

The Spreadsheet object connects to the data source, and the test connection checks out good. The query :

SELECT * FROM Purchase_Orders WHERE
(Purchase_Orders.LastName=Forms!TEMP!LastName)

The result returned is:

No value given for one or more required parameters.

This seems to be a matter of syntax and not referencing the form field properly from inside the query. If I instead use

WHERE LastName=''Smith''

it works just fine.

Can someone help me out with the proper MS object referencing convention?



1)当您尝试运行查询时表单是否打开?


2)是名称,而不是名称控件源或字段的名称,文本框实际上是LastName?控件的名称和控件源/字段名称是不同的东西。

1) Is the form open when you try to run the query?

2) Is the name, not the control source or the name of the field, of the textbox actually LastName? The Name of a control and the Control Source / Field Name are different things.



我敢肯定这不应该是太难了,但我不熟悉MS对象模型。


假设我有一个表Purchase_Orders和形式TEMP我用来查找客户的订单。表单有一个名为LastName的文本字段,用于键入新订单,但首先让我们看一下以前的订单。表单上的其他位置是Office Web Components电子表格版本11.0,它将运行查询并显示结果列表。


Spreadsheet对象连接到数据源,测试连接检查好的。查询:


SELECT * FROM Purchase_Orders WHERE

(Purchase_Orders.LastName = Forms!TEMP!LastName)


返回的结果是:


没有给出一个或多个必需参数的值。


这似乎是语法问题,而不是从查询内部正确引用表单字段。如果我反而使用


WHERE LastName =''Smith''


它运作得很好。


有人可以帮助我使用正确的MS对象引用约定吗?
I''m sure this shouldn''t be too difficult, but I lack familiarity with the MS object model.

Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer''s orders. The form has a text field named LastName for typing in new orders, but first let''s look at the previous orders. Elsewhere on the form is a Office Web Components Spreadsheet version 11.0, which will run a query and show the result list.

The Spreadsheet object connects to the data source, and the test connection checks out good. The query :

SELECT * FROM Purchase_Orders WHERE
(Purchase_Orders.LastName=Forms!TEMP!LastName)

The result returned is:

No value given for one or more required parameters.

This seems to be a matter of syntax and not referencing the form field properly from inside the query. If I instead use

WHERE LastName=''Smith''

it works just fine.

Can someone help me out with the proper MS object referencing convention?



LastName在表单上作为文本字符串输入。标识它的语法如下:


SELECT * FROM Purchase_Orders WHERE

(" Purchase_Orders.LastName =''"& Forms!TEMP !LastName&"''")

LastName is entered as a text string on the form. The syntax that identifes it is as follows:

SELECT * FROM Purchase_Orders WHERE
("Purchase_Orders.LastName= ''" & Forms!TEMP!LastName & "''")



LastName在表单上作为文本字符串输入。标识它的语法如下:


SELECT * FROM Purchase_Orders WHERE

(" Purchase_Orders.LastName =''"& Forms!TEMP !LastName&"''")
LastName is entered as a text string on the form. The syntax that identifes it is as follows:

SELECT * FROM Purchase_Orders WHERE
("Purchase_Orders.LastName= ''" & Forms!TEMP!LastName & "''")



这只是在他试图通过VBA代码进行的时候。如果从查询构建器开始,则不需要引号。

This is only if he''s trying to do it through VBA code. You don''t need the quotes if you''re doing from the query builder.


这篇关于从查询中引用表单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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