从表单运行查询 [英] Run Query from Form

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

问题描述

嘿所有,


我的目标是在下个月获得100个新线程,如果我保持这个,我可能会成功。但无论如何,这里是问题。


我有一个表单(frmData),用于输入特定客户端的信息(数字)。所以大约80个填写1个客户端。然后在查询(qryCalc)中计算该信息(总和)。因此查询显示每个客户端输入的数字总和。现在,我已将此查询插入到表单中以允许总和?领域。这只是可见的。现在,一切都有效。我可以看到入围前的答案。我目前必须运行查询,关闭表单,然后重新打开以查看总和。那么:


现在我想添加一个运行查询?表单上的命令将允许用户在输入信息后单击命令按钮,因此,?Sum? total(查询)将显示,而不关闭表单,或手动运行查询。这将允许人们检查以确保输入了正确的金额。


所以我有一个命令按钮,它应该运行查询。而是打开查询。所以你点击按钮就会打开查询。我想将此更改为不打开查询,并使其自动运行。从而更新?总和?领域。这是我使用的代码:

Hey all,

My goal is to get to 100 new threads in the next month, and if I keep this up I may make it. But anyways, here the issue.

I have a form (frmData) which is used to enter information (numeric) for a specific client. So about 80 fill-ins for 1 client. This information is then calculated (sum) in a query (qryCalc). So the query shows the sum of the numbers entered per client. Now, I have inserted this query into the form to allow for a ?sum? field. This is viewable only. Now, everything works and shows. I can see the pre-entry answer. I currently have to run the query, close the form, and reopen to see the sum. SO:

Now I am trying to add a ?run query? command on the form which will allow the user to click the command button after entering the information and thus, the ?Sum? total (query) will show, without closing the form, or manually running the query. This will allow people to check to make sure the correct amount has been entered.

So I have a command button which should run the query. Instead it opens the query. So you click on the button and the query opens. I want to change this to not have the query open and to also make it so it runs automatically. Thus updating the ?sum? field. Here?s the code I used:

展开 | 选择 | Wrap | 行号

推荐答案

qryCalc的SQL会帮助...
The SQL of qryCalc would help here...


请记住,如果您在代码中执行DoCmd.OpenQuery时有一个动作查询(您可以 - 或者当然应该有),它在设计视图中,它将显示而不执行。

也许这是你的问题?
Bear in mind, if you have an action query (you do - or certainly should have) which is in design view when you execute DoCmd.OpenQuery in the code, it will Display and not execute.
Maybe this was your problem?



qryCalc的SQL在这里会有所帮助...
The SQL of qryCalc would help here...



SEL ECT tblAnswers.ClientAutoID,Sum(tblAnswers.Answer)AS SumOfAnswer

FROM tblAnswers

WHERE(((tblAnswers.QuestionNumber)201和232之间))

GROUP BY tblAnswers.ClientAutoID

ORDER BY tblAnswers.ClientAutoID;

SELECT tblAnswers.ClientAutoID, Sum(tblAnswers.Answer) AS SumOfAnswer
FROM tblAnswers
WHERE (((tblAnswers.QuestionNumber) Between 201 And 232))
GROUP BY tblAnswers.ClientAutoID
ORDER BY tblAnswers.ClientAutoID;


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

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