To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

           


Sunday, December 1, 2002 VOLUME 1 ISSUE 10  
Contact the Editors:
Bill Warner: Compuniq@aol.com
Jim Chapman: jec@iowatelecom.net
HOME
TOPICS
News & Notes
Learn Alpha Five
Tips & Tricks
Tech Corner
Developer Spotlight
ARTICLES
Defining a Label Starting Position Revisited - Again
Defining a Label Starting Position Revisited - Again
by Bill Warner

Defining a Label Starting Position Revisited - Again In the July issue, Stan Mathews had a great idea for labels. In the September issue, I modified it to include using Query by Form. This month's article solves another problem - printing one label from a Quick Filter.

There have been two articles showing how to define a starting position for labels, so you don't have to use a new sheet every time you want to print.  The first article by Stan Mathews described his original idea, and in the second article I modified it so it would work when someone uses Query by Form.  Well, the story isn't quite over.

I have used this method for several customers, and they love it. However, one of them called me to complain that it didn't work.  It turns out that, rather than running a standard query or Query by Form to print many labels, she was printing one label at a time, and using the Quick Filter to select the record.  This meant that I had to change the script to accommodate this condition.

To see why it didn't work, it's worth reviewing the other scripts.  Stan's script worked because he included a record that had blank values for the fields that would show on the label (name, address, etc.).  His query would include the blank record, and the sort order insured that it would appear first.

However, this didn't work with Query by Form when the user didn't specify the sort order, because then the records would sort by record number.  Unless the user had the blank record as the first record, it would not appear first.  My script took this into account, assuming that they added the new feature (and the blank record) to a table with existing data.  I did this by checking to see if the current sort was by record number or not, and defined the new sort accordingly.

However, when doing a Quick Filter, the sort order could be anything, including by record number.  When it was not by record number, my script failed.  So, back to the proverbial drawing board.

I finally came up with a script that works for any sort order, and for any type of record selection (Quick Filter, Query by Form, etc.).

In this script, I retrieve the filter (qbff) and sort (qbfs).  Then I define a new value (qif) that will set the new order to make sure the blank record comes first, and then test the sort to see if it is by record number (either blank or RECNO()).

Next, I re-define the filter by including the blank record.  Then, I run a new query that will duplicate the one that the user ran, plus add the blank record.  Finally, I prompt the user for the label's starting position (see the previous articles to see the parameters for the labels).

Here's the script:



tbl= table.current()

qbfs = tbl.index_primary_get().order_get()

qbff = tbl.index_primary_get().filter_get()



qif = "IF(LNAME = \"\",\"0\",\"Z\")"



IF qbfs = "" .or. qbfs = "RECNO()"

	 qbfs = qif

	 ELSE

	 qbfs = qif + "+" +qbfs

END IF



qbff = qbff + ".or. LNAME = '' "



query.description = "Labels"

query.filter = qbff 

query.order = qbfs

query.options = ""

tbl.query_create()



clblpos = ui_get_text("LABEL POSITION","Enter position for first label","1")

lblpos=val(clblpos)



:label.preview("label_sheet")


[PRINTER FRIENDLY VERSION]
Powered by iMakeNews.com