Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing information from a forms filtered table 1

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
Hi all,

I am using a form that holds a table full of user defined filtered information. I am looking to print out the filtered information either through a report or some other kind of method by clicking on a button.

Can anybody help?

Thanks,

Woody
 
Woody,

I'm not sure what you're looking for here. If you want to print the table, just use a report (as normal). If you're looking for print one record out of that table, then you may find or
helpful.

If you're looking to print the current range/filter conditions, then here's a routine that gathers that for a given uiObject and then displays the results in a dialog box:

Code:
method getLimitInfo( uiTarget UIObject )
; -----------------------------------------------
; This routine displays information about active 
; ranges and filters on a bound UIObject.
; -----------------------------------------------

var
   tcTarget   TCursor             ; actual table.
   datFilter  DynArray[] AnyType  ; active filter 
   astrRange  Array[] String      ; active range 
   astrIndex  Array[] String      ; index fields
   dstrFinal  DynArray[] String   ; Final data
   liNoItems  LongInt             ; # array items
   siCounter  SmallInt            ; Counter var
   strCounter String              ; Counter Var
endVar

   errorTrapOnWarnings( Yes )  
   try
      tcTarget.attach( uiTarget )
   onFail
      msgStop( "Can't Show Limit Conditions",
               "Reason: The specified object ( " + 
               uiTarget.FullName + " ) is " + 
               " either not a data object or " + 
               "it's not bound to a table.  " + 
               "Please check your code." )
      return
   endTry

   tcTarget.getRange( astrRange )
   liNoItems = astrRange.size()
      tcTarget.enumFieldNamesInIndex( astrIndex )

   ; Check the conditions of the range.  There 
   ; are three cases we need to worry about: no 
   ; range, one range condition, multiple range 
   ; conditions.  The first two cases are handled 
   ; easily enough, but the latter requires some 
   ; effort, due to the way conditions are 
   ; reported by getRange.

   switch

      case liNoItems = 0 :  ; No range is applied
         dstrFinal[ &quot;Range&quot; ] = &quot;<None>&quot;

      ; One condition is applied to first field.
      case liNoItems = 1 :  

            dstrFinal[ &quot;Range&quot; ] = 
               astrIndex[ siCounter ] + &quot; Field: &quot; + 
               astrRange[ 1 ]

      ; A range is applied to first field.
      case liNoItems = 2 :  

            dstrFinal[ &quot;Range&quot; ] =
               astrIndex[ 1 ] + &quot; Field: &quot; +
               astrRange[ 1 ] + &quot;, &quot; + 
               astrRange[ 2 ]

      ; a range on the final field of the index
      otherwise :          

         for siCounter from 1 to liNoItems - 1
            dstrFinal[ &quot;Range Field &quot; + 
            String( siCounter ) ] =
               astrIndex[ siCounter ] + &quot;: &quot; + 
               astrRange[ siCounter ]
         endFor
         dstrFinal[ &quot;Range Field &quot; + 
         String( siCounter ) ] =
            dstrFinal[ &quot;Range Field &quot; + 
            String( siCounter ) ] +
            &quot;, &quot; + astrRange[ liNoItems ]

      endSwitch

   ; Fetch current filter
   
   tcTarget.getGenFilter( datFilter )
   If datFilter.size() = 0 then
      dstrFinal[ &quot;Filter&quot; ] = &quot;<None>&quot;
   else
      forEach strCounter in datFilter
         dstrFinal[ &quot;Filter on [&quot; + 
                    strCounter + &quot;]&quot; ] =
            datFilter[ strCounter ]
      endForEach
   endIf

   dstrFinal.view( &quot;Current Conditions&quot; )
   tcTarget.unAssign()

endMethod

Now, this is taken from an application I wrote awhile back, but it demonstrates the basic techniques behind the process.
You should be able to adapt this to either:

-- save dstrFinal to a text file and then open it using Execute( &quot;start whatever.txt&quot; )

-- dump it into a temporary table and print a report from that.

Hope this helps...

-- Lance
 
Lance,

Basically, I have a form which the user uses to filter for the information required. Once they are satisfied with the information displayed on the form table I want them to be able to print the results in some kind of form or text file.

Thanks,

Woody
 
You should have a pushbutton to run a query based on the current filter information and attach a report to the answer table.

Mac :)

&quot;Do not delve too deeply in the arts of your enemy and so become ensnared by them&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Woody,

I think, then, shows the underlying technique you're looking for, though you'll want to pull out the reference to setRange.

The basic idea is to:

1. Create and save a report created for the unfiltered version of the data.

2. Add code to the form that saves the filtered data to an ANSWER table using TCursors and instantiateView().

3. Use reportOpenInfo variables to change the master table of the report you creaed in Step 1 to point to the ANSWER table you created in Step 2.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top