VFP - 从表单控制报告

发布于 2024-10-12 17:13:51 字数 847 浏览 2 评论 0原文

我正在使用VFP 9.0...我正在制作发票报告,我想知道如何通过更改表单中的组合框来更改报告的内容。或者能够在报告中使用 select 和 where 子句...任何帮助将不胜感激:)

编辑澄清(根据评论而不是直接添加到问题中)

+-----------------+       +-------------------------+
|  Contract Form  |       |   Invoice Form          |
|                 |       |                         |
|                 |       | radioCustomer           |
| btnInvoiceForm -------> |    comboCustomersList   |
+-----------------+       | radioContract           |
                          |    comboContractsList   |
                          |                         |
                          | btnPreviewReport        |
                          +-------------------------+

如果我单击“预览发票”按钮,则显示合同表中的所有记录其中客户 ID (FK) = 从组合框中选取的 ID。

如果我从单选按钮中选择合同,合同组合框将起作用,显示合同 ID 列表,然后运行报告将显示合同表中的记录,其中合同 id = 从组合框中选择的 id ...

iam using VFP 9.0...Iam making an invoice report, what i want to know is how to change the contents of the report by changing lets say a combo box in a form. or be able to use select and where clause in the report...any help would be appreciated :)

EDITED FOR CLARIFICATION (per comments instead of direct add into question)

+-----------------+       +-------------------------+
|  Contract Form  |       |   Invoice Form          |
|                 |       |                         |
|                 |       | radioCustomer           |
| btnInvoiceForm -------> |    comboCustomersList   |
+-----------------+       | radioContract           |
                          |    comboContractsList   |
                          |                         |
                          | btnPreviewReport        |
                          +-------------------------+

If I click on the Preview Invoice button, show all records from contract table where customer id (FK) is = to the id picked from the combo box.

If I picked contract from the radio buttons, the contract combo box would work, showing a list of contract id(s), running the report then would show you the record from the contract table where contract id = the id picked from the combo box...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身以后 2024-10-19 17:13:51

我编辑了该消息,希望更好地理解您的表单布局,并分别启用/禁用相应的单选按钮组合框控件。我认为您需要起草两个不同的报告,无论显示各自的内容如何,​​然后根据单选按钮设置调用每个报告...例如在“btnPreviewReport”对象 CLICK 事件中...我已经粗略-在样本中...

if not empty( Thisform.radioControl.radioCustomer.Value )
   */ Customer radio button was selected
   xCustomerID = comboCustomersList.Value

   */ Run your Query
   select ... from YourTable where ... into cursor C_SampleCustomerData

   */ Run the report
   report form YourCustomerReport preview

else 
   */ Contract radio button was selected

   */ Customer radio button was selected
   xContractID = comboContractsList.Value

   */ Run your Query
   select ... from YourTable where ... into cursor C_SampleContractData

   */ Run the report
   report form YourContractReport preview
endif 

我再次根据您的描述尝试了最好的表格。

编辑——第二条评论澄清...

VFP 中的报告的好处是它们在数据环境中不需要任何硬 DBF()。但是,最好将数据字段设置为您希望拥有的 Alias.Field 引用。因此,如果您查询客户报告的数据应始终具有相同的预期别名结果...

ex:
// pre-close in case the alias we want was already left open previously
use in select( "C_CustomerResults" )
select c1.*;
   from YourCustomerTable c1;
   where c1.ID = SomeChosenID;
   into cursor C_CustomerResults readwrite 

Then, in your report, have all your fields to something like

C_CustomerResults.FirstName
C_CustomerResults.LastName
C_CustomerResults.OtherField

此示例使用了一个很长的别名,但只是为了澄清处理。

我会为您的“合同”结果别名做类似的事情。只要该别名正在使用,报告就会针对当前使用的表运行。没有什么花哨的东西,没有其他准备工作,报告中不需要数据环境设置...

通过预先查询报告中的数据样本可以帮助您“粗略”报告的布局。然后,完成表单以运行查询并显示报告,就完成了。

编辑 - 再次修改评论后续

是的...对于您的多行客户发票,同样的事情...但是您的报告有一个标题带,用于您只想在页面顶部显示一次的内容,以及一个您希望在其中显示发票“每个行项目”内容的详细信息区域,以及用于显示所有总计的报表页脚。根据复杂性,您可以在报告中添加其他“数据组”,但现在就开始吧。听起来你需要先熟悉一些可行的东西,然后再进行扩展。

如果 VFP 是您的开发平台,另一个始终拥有专门的 VFP 专家的网站是 www.UniversalThread.com。他们还支持其他论坛,但在 VFP 中,他们每天会收到 100 多个问题......

I've edited the message to hopefully better understand your layout of the form(s) with respective radio button combobox controls respectively enabled/disabled. I think you'll need to draw up two distinct reports no matter what showing respective content, then call each one based on the radio button setting... Such as in the "btnPreviewReport" object CLICK event... I've roughed-in on the sample...

if not empty( Thisform.radioControl.radioCustomer.Value )
   */ Customer radio button was selected
   xCustomerID = comboCustomersList.Value

   */ Run your Query
   select ... from YourTable where ... into cursor C_SampleCustomerData

   */ Run the report
   report form YourCustomerReport preview

else 
   */ Contract radio button was selected

   */ Customer radio button was selected
   xContractID = comboContractsList.Value

   */ Run your Query
   select ... from YourTable where ... into cursor C_SampleContractData

   */ Run the report
   report form YourContractReport preview
endif 

Again, I tried the form as best from your description.

EDIT -- second comment clarification...

The nice thing about reports in VFP is they do not pre-require any hard DBF() in the data environment. However, it would be good to have your data fields set to an Alias.Field reference you are EXPECTING to have. So, if your querying of the data for the Customer report should always have the same expected alias result...

ex:
// pre-close in case the alias we want was already left open previously
use in select( "C_CustomerResults" )
select c1.*;
   from YourCustomerTable c1;
   where c1.ID = SomeChosenID;
   into cursor C_CustomerResults readwrite 

Then, in your report, have all your fields to something like

C_CustomerResults.FirstName
C_CustomerResults.LastName
C_CustomerResults.OtherField

This example uses an otherwise long alias name but just for clarification of handling.

I would do a similar for your "contract" results alias. As long as that alias is in use, the report will run against whatever is the current table in use. Nothing fancy, no other prep, no data environment settings needed in the report...

By pre-querying a sample of the data you would have in the report can help you in "roughing" the layout of your report. Then, finish your form to run the query and show the report and you're done.

EDIT -- revised comment follow-up again

Yes... for your customer invoice with multiple lines, same thing... however your report has a header band for things you want to only show once at the top of the page, and a detail band where you would want to show content for your "each line item" of the invoice, and a report footer to show any totals. Depending on complexity, you can add additional "Data Groups" in the report, but start with this now. It sounds like you need to get your feet wet with something working first before you expand on it.

If VFP is your development platform, another website that has dedicated experts in VFP all the time is at www.UniversalThread.com. They also support other forums, but in VFP, they'll get 100+ questions thrown at it a day...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文