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?

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.

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?

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.

Hope all this makes sense and that someone can offer some suggestions. I'm
using VFP 9.0sp1 btw.

Thanks in advance,
Linn

Re: Printing labels? by Stefan

Stefan
Fri Sep 07 00:32:55 PDT 2007


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



Re: Printing labels? by Beverly

Beverly
Fri Sep 07 07:41:37 PDT 2007

Two things which have worked for me over the years in similar
circumstances have been the use of an extra "action" field which can be
used to "tag" a record when using different processes to collect mixed
and diverse records for actions such as label printing.

The other is to use a temporary local database or editable cursor to
collect the same information. In addition to simplifying the action
when the collection is finished, it provides quick information such as
how many items will be printed and allows "tricks" such as inserting
blank records to allow printing to begin at an offset point when
printing to expensive media.

The temporary local database also allows the collection process to be
saved and continued over multiple sessions. The "tagging" process has
the advantage of preventing dupes but has to be cleared after each use.

hth,
Beverly Howard

Re: Printing labels? by Dan

Dan
Fri Sep 07 08:35:48 PDT 2007

If your report is printing all of the addresses for the currently selected
person, you have the child alias selected. It sounds like the report is
running through the entire child parameterized view.

Add NEXT 1 to the REPORT FORM command. That only prints the current record.

You can certainly hard-code SET PRINTER TO (name of printer), although what
happens when the user changes the name of the printer?

Dan

Linn Kubler wrote:
> 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?
>
> 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.
> 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?
> 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.
>
> Hope all this makes sense and that someone can offer some
> suggestions. I'm using VFP 9.0sp1 btw.
>
> Thanks in advance,
> Linn



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



Re: Printing labels? by Stefan

Stefan
Fri Sep 14 01:15:07 PDT 2007


"Linn Kubler" <lkubler@chartwellwisc2.com> schrieb im Newsbeitrag
news:%23XQaVUY8HHA.464@TK2MSFTNGP02.phx.gbl...
> 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 ?
Hi Linn,

With "Set Printer To Name (cExpression)", cExpression must match
the expression you'd get via GetPrinter() or in the first column of
the result-array of APrinters(), so my guess is that your hard-coded
name does not exactly do so.


hth
-Stefan



--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



Re: Printing labels? by Linn

Linn
Mon Sep 17 11:11:31 PDT 2007

Thanks Dan, the NEXT 1 did the trick. My users don't have rights to rename
printers and this application will only be used in house.

"Dan Freeman" <spam@microsoft.com> wrote in message
news:%23hizETW8HHA.2476@TK2MSFTNGP05.phx.gbl...
> If your report is printing all of the addresses for the currently selected
> person, you have the child alias selected. It sounds like the report is
> running through the entire child parameterized view.
>
> Add NEXT 1 to the REPORT FORM command. That only prints the current
> record.
>
> You can certainly hard-code SET PRINTER TO (name of printer), although
> what happens when the user changes the name of the printer?
>
> Dan
>
> Linn Kubler wrote:
>> 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?
>>
>> 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.
>> 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?
>> 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.
>>
>> Hope all this makes sense and that someone can offer some
>> suggestions. I'm using VFP 9.0sp1 btw.
>>
>> Thanks in advance,
>> Linn
>
>