按客户编号存储和发送报告2016年 [英] Store and send reports by customer number Access 2016

查看:58
本文介绍了按客户编号存储和发送报告2016年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了网站,但没有什么比得上。我有一个名为rptAccount的月度帐户的访问报告。

每个报告按客户代码编号,3个字符的数字字符串(012)等分组。

是否有每个月发送这些帐户的快捷方式(ish)方式。它们单独打印,但作为一个大报告发送。存档很好。目前我必须进入打印预览,将每个报告页面保存为pdf,需要大约6次点击,然后我必须回到已存档的pdf并发送给电子邮件收件人。这有点长,因为通常有30多个。感谢任何帮助,宏如果可能,不熟悉VBA。

I''ve looked through the site for this but nothing quite matches. I have an Access report for monthly accounts called rptAccount.
Each report is grouped by Customer code number, a 3 character number string (012) etc..
Is there a quick and easy (ish) way to send these accounts each month. They print separately but send as one big report. That is fine for archive. At the moment I have to go to Print Preview, save each report page as a pdf which requires about 6 clicks, then I have to go back to the archived pdfs and ''send'' to email recipient. It''s a bit long winded because there are usually 30+. Thanks for any help, macro if possible, not very conversant with VBA.

推荐答案

TrevorJ,


欢迎来到Bytes!


你问的很简单。有两个部分:第一部分是简单地按客户代码过滤报告;第二部分是将每个过滤后的报告导出为PDF格式。


所有这一切都可以通过VBA获得。


你有没有你自己做过任何尝试吗?请发布您尝试过的代码。
TrevorJ,

Welcome to Bytes!

What you are asking is very simple. There are two parts: the first part is to simply filter the report by the Customer Code; the second part is to export each of those filtered reports as a PDF.

All of this is readily available using VBA.

Have you made any attempts at doing this yourself? Please post your attempted code.


非常感谢您的欢迎并花时间查看我的问题。正如我所说,虽然我正在进行在线课程,但我对VBA并不是很了解。我在论坛上找到了一些片段并开始修改它们但是我不知道在哪里放置记录集,如何在我的tblCustomers.email中引用电子邮件地址等等。这就是我到目前为止所得到的;

Many thanks for you welcome and taking the time to look at my question. As I said I''m not very good with VBA although I am doing an online course. I have found some snippets on the forums and started to modify them but I''m not sure where to put the recordset, how to reference the email addresses in my tblCustomers.email and so on. This is what I''ve got so far;

展开 | 选择 | Wrap | 行号


Trevor,


感谢您提供更多信息。


首先,此论坛的要求之一是在您向网站发布代码时使用代码标记。您只需突出显示代码并单击编辑器中的 [CODE /] 按钮即可。我已经为你上面的代码做了这个。


其次,我想首先说我宁愿教你正确的(或更好的)做事的方法,从角度来看如果我可以教你如何做得好(并且你了解 你在做什么),从长远来看你会更好。所以,我会就你的代码提出一些意见和建议,这可能不会特别回答你的问题,但可以帮助你更好地理解事情。


你说你是VBA的新手 - 我们一直都是新手,但我们都在不断学习!关于你的代码!


1.在发布程序时,我们从私有子XXXX()"到最后 End Sub 。您可以随意删除不相关的代码,但这让我们知道您已经构建了一个我们正在尝试为您排除故障的初始程序。


2.我想鼓励您过程命令#_Click()表明您至少在考虑需要做什么。但是,我建议,对于窗体上控件的命名约定(在这种情况下,命令按钮命令#),如果可能的话,请不要使用特殊字符。此外,您有一个标准的命名约定。对于您命名的每种类型的对象。例如,命令按钮将命名为cmd [Description],文本框可以命名为txt [Description]。在您的特定情况下,您的命令按钮可以命名为cmdSendReports。我不认可任何 特定的 命名约定,只有你有一个 - 并坚持使用它。当涉及MS Access用于字段控件的默认命名约定时,这一点非常重要,因为当表格中的字段CustomerName作为文本框控件添加到表单时,其名称将为CustomerName。然后,当您引用客户名称时在你的VBA背后的那个表格中,从技术上讲,你是模棱两可的,因为VBA不知道Me.CustomerName是否意味着名为CustomerName的Control。或名为CustomerName的基础字段。这并不总是(或者甚至通常)导致问题,但 可以 。再一次,这是我多年来学到的东西并传递给你。


3.在构建代码时,想一想你想做什么。再次,看起来你试图这样做。以下是我将如何处理您的特定问题:
  • 我需要一个客户代码列表
  • 我需要一个电子邮件地址列表
  • 我需要a)首先将报告保存为PDF,然后发送它们,或者b)以PDF格式发送这些报告(无论哪种方式都有效)
Trevor,

Thanks for the additional information.

First, one of the requirements on this forum is to use code tags whenever you post code to the site. All you have to do is simply highlight your code and click the [CODE/] button in your editor. I''ve done that for your code above.

Second, I want to begin by saying that I would rather teach you proper (or better) ways to do things, from the perspective that if I can teach you how to do something well (and you understand what you are doing), you are better off in the long run. So, I will make some comments and recommendations about your code which may not particularly answer your question, but may help you understand things better.

You say you are a novice in VBA--we''ve all been novices at one point, but we all keep learning! On to your code!

1. When posting procedures, it is helpful to us that you post the entire procedure from "Private Sub XXXX()" through the end "End Sub". You may feel free to delete irrelevant code, but this lets us know you have an initial procedure built that we are trying to troubleshoot for you.

2. I want to encourage you that your procedure Command#_Click() demonstrates that you are at least thinking about what needs to be done. I would recommend, however, that the for the naming convention of the controls on your forms (the Command Button Command#, in this case) refrain from using special characters, if at all possible. Also, that you have a standard "naming convention" for each type of object you name. For example a Command Button would be named "cmd[Description]", Text boxes could be named "txt[Description]". In your particular case, your Command Button could be named "cmdSendReports". I don''t endorse any particular naming convention, only that you have one--and stick with it. This is important when it comes to the default naming convention that MS Access uses for your field controls, as the Field CustomerName from a Table, when added to a Form as a Text Box control will have the name "CustomerName." Then, when you refer to "CustomerName" in your VBA behind that form, technically speaking, you are being ambiguous, because the VBA doesn''t know whether Me.CustomerName means the Control named "CustomerName" or the underlying Field named "CustomerName." This does not always (or even usually) cause problems, but it can. Again, this is stuff I''ve learned over the years and pass along to you.

3. When building your code, think through what you want to do. Again, it looks like you''ve tried to do that. Here is how I would approach your particular issue:
  • I need a list of Customer Codes
  • I need a list of e-mail addresses
  • I need to either a) save the reports to PDF first, then send them, or b) send those reports as PDFs (either way would work)
展开 | 选择 | 换行 | 行号


这篇关于按客户编号存储和发送报告2016年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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