开发者

VFP - Control report from form

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 comb开发者_如何转开发o 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...


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜