在Microsoft Access中自动生成报告 [英] Auto-generating reports in Microsoft Access

查看:582
本文介绍了在Microsoft Access中自动生成报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在为附属医院建立更新的Microsoft Access数据库,以保留潜在医学研究文档的时间表.数据库本身是独立的,因此没有真正的后端可以说出来(这很伤我,但我无法控制它们如何处理数据).它目前仅包含一个表,其中包含所有需要的必填字段.我希望每周,每月,每季度和每年自动生成报告.但是,我必须承认,我的vba编码能力充其量是充斥的.我的问题是这样的:

Currently I am in the process of building an updated Microsoft Access database for our affiliated hospital to keep a timeline of documentation for potential medical studies. The database itself is standalone, so there is no real back end to speak of (which hurts me, but I have no control over how they handle their data). It currently holds only one table with all the necessary fields needed. I'm looking to have reports generate automatically every week, month, quarter, and year. However, I must admit my vba coding abilities are spotty at best. My questions are this:

  1. 我需要使用什么代码来生成所述报告?

  1. What code would I need to use to generate said reports?

我是否需要根据需要生成报告的时间为每种类型的报告创建单独的查询,还是可以在一个查询中对所有报告进行编码,而不会互相干扰?

Would I need to create separate queries just for each type of report based on when it needs to be generated, or can I code it all in one query without the different codes interfering with each other?

如果需要任何其他信息或说明,我很乐意为您提供.

If any other information or clarification is needed, I'd be happy to give you what I can.

推荐答案

从VBA或宏调用Report时,可能有两件事对您有用:

When calling a Report from VBA or from a macro, two things could be usefull to you:

  1. 提供condition,例如
    docmd.OpenReport "someReport",acViewPreview,,"[examDate] > Date() - 30"
  2. 提供一个OpenArg,vba可以在报表中使用它来更改周期性(例如,"M"代表每月,"w"代表每周"),例如
    docmd.OpenReport "someReport",acViewPreview,,"[examDate] > Date() - 30",,"W"
  1. providing a condition, like
    docmd.OpenReport "someReport",acViewPreview,,"[examDate] > Date() - 30"
  2. providing an OpenArg, which can be used by vba in your report to change the periodicity for example ("M" for Monthly and "w" for Weekly"), like
    docmd.OpenReport "someReport",acViewPreview,,"[examDate] > Date() - 30",,"W"

这些技巧应允许您设计一次报告,然后将其与动态时间范围和分组一起使用.

Those tricks should allow you to design a report ONCE, then use it with dynamic time range and grouping.

这篇关于在Microsoft Access中自动生成报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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