Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Subform - Reports (Read 3610 times)
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Subform - Reports
Feb 13th, 2018 at 2:27am
Print Post Print Post  
Hello, I am trying to create a command button in a (form style) Subform that generates an html preview report. Here is my problem. First of all, I need to be able to pull all the records from within a date range,  say 02/01/2018..02/28/2018, then I need it to generate a report with all the records between that date range (not specific to the record on the Main highest level form). But what happens is, when I press the button the report comes up blank. I then tried to create this same report button on the Main highest level form and targeted it towards the subform, same result, a blank report. Actually, the only time the report works perfectly is when I run it specifically from that application. As in, I opened up the Subform from the application menu in it's own tab, retrieve the records I want, then press the button. However, this does not work for me, I want to be able to run this report on the fly, from within the main application,  or rather, the main form. I do not want to have my boss have to open up this other form separately in another tab and have to figure out how to use it and what not. I want them to just be able to push a button like normal. Are there any solutions for this? I was thinking that I might need to run programming from within the report, like GetValues and create a string array or something, then somehow force those into the report, but I really have no idea at this point. As far as reports I only have three commands to work with and I'm not sure how to use those to make  it do what I want it to do. As usual, thank you for your time and support.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Subform - Reports
Reply #1 - Feb 13th, 2018 at 2:12pm
Print Post Print Post  
If you want to run a report on another form that is not the current Top Level form, or a different set of records than what you currently have retrieved, you will want to use @XResultSetSearch() and @XResultSetPrintReport(). Be sure to use XResultSetClose() otherwise you will leave records as locked.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #2 - Feb 13th, 2018 at 2:29pm
Print Post Print Post  
Awesome, thank you.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #3 - Feb 15th, 2018 at 3:14pm
Print Post Print Post  
Here's my code thus far:

Code
Select All
#include "sbasic_include.sbas"

var vDate as String
var vHandle as Int
var vPrint as String

vDate = @FormFieldValue("Work", "Work_Date", 0)
WriteLn(vDate)
vHandle = @XResultSetSearch("Action.db", "Work", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Work_Date=vDate")
WriteLn(vHandle)
vPrint = @XResultSetPrintReport("Techs Receivable", @XResultSetForm("Work"), REPORT_MODE_HTML_PREVIEW)
XResultSetClose(@XResultSetForm("Work"))
 



My problem is that the slate returns as:

02/01/28..02/28/18
-1

And the HTML Preview report is still generating as blank.

I'm not sure but what I think is happening is that it's not taking my retrieve spec correctly to lookup records. The retrieve spec I'm typing in is a date range, like "02/01/28..02/28/18" above. But I'm not sure if this needs to be enclosed in quotation marks or with brackets or requires some other annotation to work correctly.

Note: "ACTION" is main form. "Work" is SubForm.
  
Back to top
 
IP Logged
 
PianoMan
Member
Members
*
Offline


No personal text

Posts: 44
Joined: Oct 13th, 2004
Re: Subform - Reports
Reply #4 - Feb 16th, 2018 at 5:02pm
Print Post Print Post  
Instead of "!Work_Date=vDate", try this:
"!Work_Date=" + vDate
  
Back to top
IP Logged
 
PianoMan
Member
Members
*
Offline


No personal text

Posts: 44
Joined: Oct 13th, 2004
Re: Subform - Reports
Reply #5 - Feb 16th, 2018 at 5:05pm
Print Post Print Post  
Also, look like you need to change the database to it's full name:
"Action!Work". So you'll end up with this:

"Action.db", "Action!Work", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Work_Date=" + vDate
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Subform - Reports
Reply #6 - Feb 16th, 2018 at 8:24pm
Print Post Print Post  
You should also not be using @XResultSetForm(). @XResultSetSearch() returns a handle to a Resultset, That is the handle you will want to be using as long as it is greater than or equal to 0.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #7 - Feb 18th, 2018 at 2:48pm
Print Post Print Post  
The handle I keep getting back is -1.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #8 - Feb 18th, 2018 at 2:58pm
Print Post Print Post  
I just realized something though that might be the problem. I'm asking it to call from "Action.db". I'm actually working with the "Action.dsr" and the actual "Action.db" is on another computer with the Server and it is not even updated to have this "Work" subform yet. Could that possibly be a problem calling the code? And if so is there a work around to where I could test this out and make sure it works before reconciling the database? Otherwise, I'll have to reconcile it first then test it out and so on.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #9 - Feb 18th, 2018 at 3:23pm
Print Post Print Post  
Here's what I have now but it's still not working. Still returning a "-1."

Code
Select All
#include "sbasic_include.sbas"

var vDate as String
var vHandle as Int
var vPrint as String

vDate = @FormFieldValue(@Layout, "Work_Date", 0)

vHandle = @XResultSetSearch(@FN, @Layout, SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Work_Date=" + vDate)
WriteLn(vHandle)

	If(vHandle > -1)
		{
			vPrint = @XResultSetPrintReport("Techs Receivable", vHandle, REPORT_MODE_HTML_PREVIEW)
		}

XResultSetClose(vHandle)
 

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Subform - Reports
Reply #10 - Feb 18th, 2018 at 8:31pm
Print Post Print Post  
Unless you are running this on the same form that is calling this code, you will want to use the name of that form, rather than @layout.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #11 - Feb 19th, 2018 at 1:13am
Print Post Print Post  
Changed it, but still am not getting anywhere.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Subform - Reports
Reply #12 - Feb 19th, 2018 at 2:17pm
Print Post Print Post  
The second argument is the full database name as PainoMan pointed out in post #6.

Another reason you may get a -1 is if you have application security set on this application, and either the XUsername and XPassword are not set or they are set but not to a valid login for this application.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Subform - Reports
Reply #13 - Feb 20th, 2018 at 12:00am
Print Post Print Post  
Here's my current code:

Code
Select All
#include "sbasic_include.sbas"

var vDate as String
var vHandle as Int
var vPrint as String

vDate = "!Work_Date=" + @FormFieldValue("Work", "Work_Date", 0)

vHandle = @XResultSetSearch(@FN, "Action!Work", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Work_Date=..")
WriteLn(vHandle)

	If(vHandle > -1)
		{
			vPrint = @XResultSetPrintReport("Techs Receivable", vHandle, REPORT_MODE_HTML_PREVIEW)
		}

XResultSetClose(vHandle)
 



I've removed all application security for all forms and reports, and I still get "-1". I've tried the button (on element entry) from the main form, from the subform in the main form, and from the subform by itself in it's own tab. I've also tried the button after retrieving all records. I've also changed the search spec to just ".." instead of a variable, and I've also tried the search spec "/" and I still get -1. I'm not sure why I'm not getting anything. I've also tried writing "LE0" instead of "Work_Date" as that's the original name that the "Work_Date" name is bound to. And I still get nothing. All I can figure is that I should try to reconcile it to the main application "Action.db" then try it in real time from there. But I'm not sure if that will even work.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Subform - Reports
Reply #14 - Feb 20th, 2018 at 5:29pm
Print Post Print Post  
actiontech wrote on Feb 20th, 2018 at 12:00am:
I've removed all application security for all forms and reports,


Did you remove all Application Security or all Security for those layouts? They are two separate things. Application Security includes the layout security. If you are still prompted for a username and password when opening the file, you still have Application Security.

A -1 is going to be caused by 4 things.
1: An incorrect path in argument 1.
2: The Application specified in argument 1 is locked.
3: The Application specified in argument 1 is password protected and the X Username and X Password in this file is not a valid login for that application.
4: The full Database name in argument 2 is wrong.

Since you are using @FN, we can eliminate 1 and 2. So that leaves 3 and 4. One of those is what is wrong.

The field referenced in argument 5(or any field reference after that in additional arguments) will only affect the records returned in that ResultSet. IE: If you spell a field name wrong or have improper retrieve criteria, your ResultSet handle will be greater than -1 but you will have 0 records in that ResultSet.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print