MS Access数据库宏 [英] MS Access Database Macro

查看:97
本文介绍了MS Access数据库宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拥有数千条客户记录的数据库。现在我使用一个宏来提示用户输入客户注册号,然后将记录导出到excel。它在每年导出之前提示用户。有没有办法提示用户注册一次,然后将值存储在查询条件中引用的变量中,以便连续将记录导出到excel。我想要单独的excel表,所以我不想使用联合查询。谢谢。

I have a database that has thousands of customer records. Right now I use a macro that prompts the user for the customer registration number and then exports the record to excel. It prompts the user prior to exporting every year. Is there any way to prompt the user once for the registration number then store the value in a variable that is reference in the criteria of the queries so it consecutively exports the records to excel. I want seperate excel sheets so I do not want to use a union query. Thanks.

推荐答案


我有一个拥有数千条客户记录的数据库。现在我使用一个宏来提示用户输入客户注册号,然后将记录导出到excel。它在每年导出之前提示用户。有没有办法提示用户注册一次,然后将值存储在查询条件中引用的变量中,以便连续将记录导出到excel。我想要单独的excel表,所以我不想使用联合查询。谢谢。
I have a database that has thousands of customer records. Right now I use a macro that prompts the user for the customer registration number and then exports the record to excel. It prompts the user prior to exporting every year. Is there any way to prompt the user once for the registration number then store the value in a variable that is reference in the criteria of the queries so it consecutively exports the records to excel. I want seperate excel sheets so I do not want to use a union query. Thanks.



您能否稍微介绍一下宏当前的工作原理?如何打印几个不同的报告,每个报告一年?


设置一个保存注册号的变量应该是一个相对简单的事情(需要知道注册号码的格式(例如数字,文本等)。


Brad。

Can you expand a little bit on how your macro currently works? How are you getting it to print several different reports with a single year on each?

It should be a relatively simple thing to set up a variable that will hold your registration number (need to know what format the registration number is in (e.g. number, text, etc.)).

Brad.



您能否稍微介绍一下宏当前的工作原理?如何打印几个不同的报告,每个报告一年?


设置一个保存注册号的变量应该是一个相对简单的事情(需要知道注册号码的格式(例如号码,文字等)。


布拉德。
Can you expand a little bit on how your macro currently works? How are you getting it to print several different reports with a single year on each?

It should be a relatively simple thing to set up a variable that will hold your registration number (need to know what format the registration number is in (e.g. number, text, etc.)).

Brad.



这是它的要点。我已经扩展到展示行动论点。我的查询在标题为Registration#的条件的条件字段中有[请输入Reg#],这是我提示输入的内容。我希望这会有所帮助。


行动


输出


对象类型查询

对象名称2005详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)


OutputTo


对象类型查询

对象名称2006详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)


输出


对象类型查询

对象名称2007详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)


Here is the gist of it. I''ve expanded to show the action arguments. My query has [Please enter Reg #]in the criteria field of the column titled Registration #, which is what I am prompting the use to enter. I hope this helps.

Action

OutputTo

Object type query
Object name 2005 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)

OutputTo

Object type query
Object name 2006 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)

OutputTo

Object type query
Object name 2007 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)



以下是它的要点。我已经扩展到展示行动论点。我的查询在标题为Registration#的条件的条件字段中有[请输入Reg#],这是我提示输入的内容。我希望这会有所帮助。


行动


输出


对象类型查询

对象名称2005详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)


OutputTo


对象类型查询

对象名称2006详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)


输出


对象类型查询

对象名称2007详细信息(查询名称)

输出格式Microsoft Excel 97-2003(* .xls)
Here is the gist of it. I''ve expanded to show the action arguments. My query has [Please enter Reg #]in the criteria field of the column titled Registration #, which is what I am prompting the use to enter. I hope this helps.

Action

OutputTo

Object type query
Object name 2005 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)

OutputTo

Object type query
Object name 2006 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)

OutputTo

Object type query
Object name 2007 Detail (name of the query)
output format Microsoft Excel 97-2003 (*.xls)



首先,我建议选择输入Reg#。查询中的条件。


其次,将未绑定的txtBox添加到按钮所在的表单中(即输出输出)。您可以将其称为RegNum或类似的东西。


第三,为您的查询添加引用此新字段的条件(例如Forms![frmMAIN]![RegNum]。


四,将此代码添加到按钮...

First, I would suggest taking the "Enter Reg#" criteria out of your Query.

Second, add an unbound txtBox to the form that your button is on (that lauches the output). You could call it RegNum or something like that.

Third, add criteria to your Query that references this new field (e.g. Forms![frmMAIN]![RegNum].

Fourth, add this code to your button...

展开 | 选择 | Wrap < span class =codeDivider> | 行号


这篇关于MS Access数据库宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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