如何在表单上显示查询结果 [英] How to show a query result on a form
问题描述
大家好
我有一个显示总小时数的查询,我想在表格上显示这些信息(作为文本框或标签)。
我该怎么做?
提前谢谢
Hi Everyone
I have a query which shows total number of hours and I want to display this information on a form (as a text box or a label).
How can I do it?
Thanks in advance
推荐答案
大家好
我有一个显示总小时数的查询,我想在表格上显示这些信息(作为文本框或标签)。
我该怎么办?
提前付款
Hi Everyone
I have a query which shows total number of hours and I want to display this information on a form (as a text box or a label).
How can I do it?
Thanks in advance
您可以按如下方式使用DLookup功能:
YourTextbox = DLookup(" [TotalHours]",YourQuery)
使用DLookup而不是DSum是因为你声明求和是在查询本身完成的。
You can use the DLookup function as follows:
YourTextbox = DLookup("[TotalHours]" , "YourQuery")
The DLookup rather than DSum was used because the You stated that the summation is done in the query itself.
感谢你的回复它正在工作:)
我现在需要做的是根据查询在表单上显示总字段y哪里有7个不同的行[employeeID],我需要提取从表单上的组合框中选择的employeeID的总数。
任何想法怎么做?
先谢谢
Thanks for the reply it is working :)
What I need to do now is to show total field on the form based on a query where there are 7 different rows [employeeID] and I need to extract the total of the employeeID which is choosen from the combo box on the form.
Any ideas how to do it?
Thanks in Advance
感谢您的回复,它正在发挥作用:)
我现在需要做的是根据查询显示表单上的总字段,其中有7个不同的行[employeeID],我需要提取从中选择的employeeID的总数表格上的组合框。
任何想法怎么做?
先谢谢
Thanks for the reply it is working :)
What I need to do now is to show total field on the form based on a query where there are 7 different rows [employeeID] and I need to extract the total of the employeeID which is choosen from the combo box on the form.
Any ideas how to do it?
Thanks in Advance
同样,我使用的是DLookup而不是DSum,因为如果我理解正确,你的查询就会得到每个employeeID的总数,因此你只需要查看总数。如果查询对每个必须合计的employeeID都有几个条目,你可以使用DSum。
如果EmployeeID是表格中的数字数据类型,请尝试这样做。
YourTextbox2 = DLookup(" [TotalHours]",YourQuery," [EmployeeID] ="& Me!YourCombo)
试试如果EmployeeID是表格中的文本数据类型。
YourTextbox2 = DLookup(" [TotalHours]",'YourQuery"," [EmployeeID] =''" ;& Me!YourCombo&"''")
Again, I am using DLookup rather than DSum because, if I understand you correctly, your query has the total for each employeeID, hence you just need to look up that total. You would use DSum if the query has several entries for each employeeID that have to be totaled.
try this if EmployeeID is a numeric data type in your table.
YourTextbox2 = DLookup("[TotalHours]" , "YourQuery", "[EmployeeID] = " & Me!YourCombo)
try this if EmployeeID is a text data type in your table.
YourTextbox2 = DLookup("[TotalHours]" , "YourQuery", "[EmployeeID] = ''" & Me!YourCombo & "''")
这篇关于如何在表单上显示查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!