Anyone has a mini sample...?

I’m working on collecting info using textfields, make some calculation and send the results to a report.
Anybody got a mini example that I can take a look at? Or point me in the right direction. Check for samples but basically from listbox.
Greatly appreciated.

Hello Benny. I see that no one has responded to your request so let me have a go at it.

Let’s say that you create a desktop Xojo application. On the Window1, you drag two textboxes onto it which will be named “TextField1” and “TextField2”. Then drag a Label over to the window which will be named “Label1” which will display the results of our simple calculation.

Click on the Window1 itself and lets add a method (either by pressing Ctrl+Shift+M or choosing the menu option of Insert>Method) named CalculateResults. So, change the “Method Name” to be “CalculateResults”. Then paste the body of the below code into the middle section.

  DIM cFirst AS String = TextField1.Text
  DIM cSecond AS String = TextField2.Text
  
  DIM nFirst AS Integer = VAL( cFirst )
  DIM nSecond AS Integer = VAL( cSecond )
  
  DIM nResult AS Integer = nFirst + nSecond
  self.Label1.Text = STR( nResult )
  

You’re probably wondering what calls the CalculateResults method? If you double click on TextField1 and and add the event handler of “TextChange” and just put in a line that says self.CalculateResults()

Now run your application. If you type numbers into the text fields, then the result should automatically be displayed in the Label1 field. I hope this helps you get started.

You may read this thread:

https://forum.xojo.com/38674-listbox-calculation-and-sum

Thank you very much Kevin and Emile,
With the example you all provided, I’ve created the info gathering and calculation.
I need help with the reporting side.

  1. How do you set up a report designer to receive the calculated field?
  2. How to send the field to the report generated by the report designer?

Greatly Appreciated.

The truth is that I don’t use the Xojo report writer for my reporting. If you have serious reporting requirements, check out BKeeney Shorts .

For most of my reporting in my day job, I create an HTML file showing the results and then use ShowURL() to display that output in a browser. With HTML I can get (almost) all of the output control I need. If I need a PDF, then I use wkHTMLToPDF which allows me control of the page layout, headers, footers, margins, and other aspects of creating output.

I know this wasn’t the answer you were looking for, but I hope this helps you think about a potential different solution.

Thank you very much Kevin,
I was actually looking into that myself.
Apparently, many xojo are using as you suggest the HTML format as output.

I’m looking into creating HTML format in a different software with the layout and re-writing it in xojo.
Is there any other more efficient way of generating html formatted layout?

Try out my HTML classes in this project:

HTMLTest.zip

[quote=340436:@Benny Lee]Thank you very much Kevin,
I was actually looking into that myself.
Apparently, many xojo are using as you suggest the HTML format as output.

I’m looking into creating HTML format in a different software with the layout and re-writing it in xojo.
Is there any other more efficient way of generating html formatted layout?[/quote]

my application create html report and then generate pdf using wkhtmltopdf. I manage to make the reports table-driven and 2 method for tabular report and columnar report. Any other fancy report like invoice and documents has to been done individually.

I bought BkeeneyShort a few years back to make a add-on to my application so client can create their own reports but did not have time to work on that yet.

[quote=340436:@Benny Lee]
I’m looking into creating HTML format in a different software with the layout and re-writing it in xojo.
Is there any other more efficient way of generating html formatted layout?[/quote]

I haven’t looked at what Simon posted above with his HTMLTest.zip file (yet), but something that has helped me immensely is a method I created called RecordSetToHTML(). I get the data just as I want it via a SELECT, View, or a Stored Procedure and then get that recordset into Xojo. I call that method which translates the Recordset into Table Header () tags and each row into a Table Detail (). It even handles setting EVEN and ODD row styles. I place the CSS into a wrapper HTML body and it produces HTML that looks great. Works really fast.

The wkHTMLToPDF helps with headers and footers including the “Page X of Y” notation.

All of this might be a struggle for the first or second report, but then you have the methodology to create a ton of reports really quickly from that point on.

I second the vote for BKeeney Shorts. Pretty steep learning curve but I love it now.

[quote=340460:@Simon Berridge]Try out my HTML classes in this project:

HTMLTest.zip[/quote]

just look at your HTMLClass and found it very useful to do documents and reports that is not the usual columnar or tabular report.
Decide to include the HTMLClass to include my toolbox

to create a new tabular or columnar report, it take me around 1-2 minute.

create the view with the report name but with a qry in front… so it report is rptStock10, then view will be qryrptStock10.
Add them into my report definition table, set a few indicator and appear in the listbox for my report generator.

Thank you very Kevin, William and Richard for the reply,
I’ll take a lot at the project and the HTMLclass.
Thank you very much.