Re: Printing labels? by Linn
Linn
Fri Sep 07 12:27:07 PDT 2007
Thanks Stefan, and everyone for your suggestions. I like the query to
cursor idea and it looks like it's working for me. I am running into
another problem though that maybe you can help with. When I use these
commands:
SET PRINTER TO NAME Gen_Label
REPORT FORM labels\address.lbx TO PRINTER NODIALOG
I get an error: Error accessing printer spooler. Now the printer, Gen_Label
is a networked printer and I noticed in the help that, "When you direct
output to a network printer, output prints or collects in a print spooler
until a new SET PRINTER command is issued." Could this be my problem? If
so, am I using the commands wrong or is there something I've missed? Maybe
I need to use the other form of Set Printer:
SET PRINTER TO NAME \\myserver\Gen_Label ?
Thanks much,
Linn
"Stefan Wuebbe" <stefan.wuebbe@gmx.de> wrote in message
news:%23lq93FS8HHA.1188@TK2MSFTNGP04.phx.gbl...
>
> "Linn Kubler" <lkubler@chartwellwisc2.com> schrieb im Newsbeitrag
> news:Oi4klQN8HHA.2208@TK2MSFTNGP06.phx.gbl...
>> Hi All,
>>
>> I am trying to put together a simple label printing program but, of
>> course, am having a small problem(s). I have my data setup following a
>> previous post on relating views. I have a view with names and I use the
>> selected name to then query another view for addresses. Each name may
>> have more than one address.
>>
>> In the second view I select the address I am interested in and have
>> defined a report with the layout that I want. Problem is that if I print
>> someone with more than one address all their addresses are printed, not
>> just the address I selected. Anyone know of any examples of how to do
>> this? Or a better approach I should be taking?
> Hi Linn,
>
> Reports always Scan/Endscan the current workarea at runtime from
> top to bottom. That is, unless you use the For or Next clause of the
> Report command.
>
> So you can use the report's dataenvironment and place your aliases
> and their properties (filters, xbase relations) there.
> (In that case, the aliases are usually sorted "upside-down", e.g. a
> child table must be open in the currently selected workarea to fill the
> report's detail band instead of its parent alias filling the report's
> group /
> page headers.)
>
> Or you can avoid the report's DE and create a temporary data
> "snapshot" instead, containing exactly those data you want to print,
> e.g. by using a SQL "Select .. Into Cursor crsReport ..." right before
> the Report Form command.
> Often one single SQL result cursor is enough to display parent table
> and several children via outer joins.
> That approach is IMO the best one, much easier to maintain, since
> often a single SQL statement can replace a complicated DE with
> a lot of aliases, relations, filters and stuff.
>
> If you do want to use a DE and local views inside of it, you can
> "parameterize" them:
> Create View As Select ... Where fieldExpr = ?myParameter
> and the open them with Use .. NoData or .NoDataOnload=.T. in the DE.
> At runtime, you can Requery() them whenever you want:
> Local myParameter
> myParameter = <your value>
> Requery('yourView')
>
>
>> I thought about using scatter to an object but then I didn't know how to
>> reference that object in the report designer. I'm thinking it is a
>> scoping issue, I don't quite know how to make the scattered object
>> global.
>
> You can declare it
> Public oRecord
> oRecord = Scatter Name ...
> For a report, it is enough to use an undeclared variable though and
> use the Private keyword to protect previous stack levels.
> However. I'd recommend the temporary cursor approach.
>
>
>> To print the labels we have a fancy thermal label printer with 4" x 5"
>> labels. I've only been using the print preview so I don't know if it
>> will work for sure or not. With that in mind, is there anyway to hard
>> code the printer so that the user doesn't have to select it each time?
>
> You can Set Printer To 'yourprinter' at runtime right before you
> run the report.
> Users can choose the correct one via GetPrinter() and your code
> might store their choice in a custom resource (e.g. a key in Win
> Registry HKCU or a "settings.dbf" or a plain text file in %appdata%
> or something like that).
>
>> Also, we want to print only one label at a time, not a set of records,
>> just the person and address combination the user selects.
>
> You can do so by filtering the data via SQL Where (see above)
> or xbase Set Filter or use the For clause of the Report command.
>
>
> hth
> -Stefan
>
>
>
> --
> |\_/| ------ ProLib - programmers liberty -----------------
> (.. ) Our MVPs and MCPs make the Fox run....
> - / See us at www.prolib.de or www.AFPages.de
> -----------------------------------------------------------
>