如何为Access Report执行多个选择查询 [英] How to do multiple select queries for Access Report

查看:283
本文介绍了如何为Access Report执行多个选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个查询将在我的报告的onopen事件上运行。我使用docmd.openquery进行选择查询问题是我可以在后台看到所有这些弹出窗口。我也使用close query命令,setwarnings为false和true。任何人都可以给我一些示例代码,使用任何示例数据库使用3个泛型选择查询,然后使用该数据为我的报告创建一个临时表所有在vba代码中。我可以使用临时表作为我的报告的记录源。我确实将strSQL用于我的动作查询。这是我需要帮助的选择查询。我知道这可以通过使用qrydef和记录集来完成,我只是不明白如何将它组合在一起。请帮我。我有很多报告都有那些小弹出窗口,如果我可以得到一个帮助,我应该能够修复我的其他报告。你可以给予任何帮助。绝望!

I have multiple queries that will run on my onopen event of my report. I use the docmd.openquery for the select queries the problem is I can see all these popup in the background. I do use the close query command also and the setwarnings to false and true. Can anyone give me some sample code that uses like 3 generic select queries using any sample database and then uses that data to create a temp table for my report all in vba code.I can use the temp table as my record source of the report..I do use the strSQL for my action queries.it''s the select queries that I need help on. I know this can be done by using qrydef and recordsets I just don''t understand how to put it together. please help me. I have many reports that have those little popups and if I can get help on one I should be able to fix my other reports. Thnks so much for any help you can give. Desperate!

推荐答案

您可以在VBA代码中使用DAO或ADO来选择数据,UPDATE数据或INSERT数据。


我会举一个老DAO的例子,因为它可能有点简单。

1)从表格的代码页转到工具/参考资料。

2 )勾选引用Microsoft DAO 3.6对象库

它可能已被勾选。


现在您可以使用DAO直接与数据库对象进行交互。

你需要的第一件事是数据库的实例
You can use eithe DAO or ADO in VBA code to SELECT data, UPDATE data or INSERT data.

I will give you an example of the older DAO because it might be a bit simpler.
1) From the code page of your form goto tools/references.
2) Tick the reference "Microsoft DAO 3.6 Object Library"
It may already be ticked.

Now you can use DAO to interract directly with your database objects.
First thing you will need is an instance of your database
展开 | 选择 | Wrap | 行号


非常感谢..在工作中淹没了&没有机会回复..如果我的选择查询使用来自prev查询示例的信息,这仍然有用:我运行qry1..now qry 2使用来自qry1&的信息另一个表..qry 3使用来自qry 2的信息,依此类推,直到我的上一个查询为我的报告创建表。所有这些查询都需要先在表单中运行,或者作为报告运行,这是我想要的。困惑?
Thanks so much ..been swamped at work & had not had chance to reply..will this still work if my select queries uses info from the prev query example: I run qry1..now qry 2 uses info from qry1 & another table..qry 3 uses info from qry 2 and so on until my last query creates the table for my report..all these queries need to be run prior either in a form or as a report which is what I want..still confused?


我不清楚你在做什么,所以我只能给你一般的想法。


拿来自query1的代码


例如
I don''t have a clear understanding of what you are doing so I can only give you general Ideas.

Take the code from query1

for example
展开 | 选择 | Wrap | 行号


这篇关于如何为Access Report执行多个选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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