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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing reports / Number field questions

Status
Not open for further replies.

DuffyW

Programmer
Feb 7, 2000
6
US
Two questions: (VFP 6)<br>
A: If I choose &quot;print report&quot; fronm the application I have created, and choose &quot;print current&quot; it always prints the LAST one in teh table, not the one I've scrolled to (in a form wizard) how do I specify that the form shown in the one I want translate to the report?<br>
<br>
2: This program is for a clinic with a network. How would I create a function to scan the field in the table for the highest number, check it against the variable, and if the variable is higher, permanently add 1 to it, and then use it in a field on a wizard-generated form? It's a multi-user program, and it's supposed to automatically assign patients a new patient #, but it has to be from a variable, and when the &quot;ADD&quot; button on the form is clicked, because it will be in use by more than one user. Any help is greatly appreciated. Thanks!!!! -Duffy <p>-Duffy W.,<br><a href=mailto:chocklit@intrstar.net>chocklit@intrstar.net</a><br><a href= > </a><br>
 
If I understand the question (#2), I whould do the following; create an index on the patient database, the key being the patient #. At the point that you are ready to write the record activate this index, goto bottom & add 1 to that patient id & write out the new record. Am I oversimplfying this or missing something?, let me know! The key is, not to generate the new patient # until, you are ready to write the new record.
 
Do not full understand your question #1 but it sounds like when you created the report form, a database was added to the report form enviroment and the exact same enviroment does not exist when you want to print a record from the tables. Go into the report form and check the enviroment. Sounds like the report form is moving you to the bottom of the database. I, for one, hate the enviroment feature of the report form because it never seems to work consistently. I always clear the data enviroment and set the databases manually the way I want them and then call the report form. I do this because then I do not need 20 report forms to print info from one database, I only need one report form per index. If you turn the enviroment off try adding the record number or the patient Id to the report form call.<br>
<br>
Report form xxxxx for recno() = PassedParameter<br>
or <br>
Report form xxxx for PatientId = AnotherTableIdField<br>
<br>
To your Question Number 2 , I have a table of nextnumbs and a function I wrote to get the next number from the table. This way I can control Purchase order numbers that need to change each Month / Year. The table alway has one record in it and the field you call is always replaced with the next number to use. It also self maintains the Month and Year fields. The function cade and table struct follow.<br>
<br>
*/***************************************************************************<br>
*/Program : NextNumb<br>
*/System : System Library<br>
*/Purpose : Return the next number of the field requested<br>
*/Syntax : string=nextnumb(field)<br>
*/Returns : string<br>
*/Parameter : field - string - name of the field to return the value of<br>
*/Defaults : field= &quot;ID&quot;<br>
*/Requires : database nextnumb<br>
*/Changes : value of field <br>
*/Calls : <br>
*/Version : 1.0<br>
*/Dated : 03/12/94<br>
*/Written By: David W. Grewe<br>
*/***************************************************************************<br>
*& type of prg :<br>
*/***************************************************************************<br>
*/ Record Of Change<br>
*/ <br>
*/***************************************************************************<br>
parameter pcField<br>
if empty(pcField) or type(&quot;pcField&quot;)#&quot;C&quot;<br>
pcField=&quot;ID&quot;<br>
endif<br>
*<br>
lcAlias = alias()<br>
if used(&quot;NEXTNUMB&quot;)<br>
select NEXTNUMB<br>
else<br>
=dbfopen(fcSysDbf+&quot;NEXTNUMB&quot;,&quot;NEXTNUMB&quot;)<br>
endif<br>
*<br>
* lock the database so noone else can have the same number<br>
*<br>
do while !rlock()<br>
wait &quot;Failed to lock the Next Number Database, Waiting 1 second&quot; window timeout 1<br>
wait clear<br>
enddo<br>
*<br>
* check the database month in case the numbers need reset.<br>
*<br>
if month(date()) != NEXTNUMB.MONTH<br>
replace NEXTNUMB.MONTH with month(date())<br>
replace NEXTNUMB.ORDER with 1<br>
endif <br>
*<br>
* check the database Year in case the numbers need reset.<br>
*<br>
if year(date()) != NEXTNUMB.YEAR<br>
replace NEXTNUMB.YEAR with year(date())<br>
replace NEXTNUMB.INVOICE with 1<br>
endif <br>
*<br>
* get the next number<br>
*<br>
lnNextNumb = (NEXTNUMB.&pcField)<br>
replace NEXTNUMB.&pcField with lnNextNumb + 1<br>
unlock in NEXTNUMB<br>
*<br>
if !empty(lcAlias)<br>
select (lcAlias)<br>
endif<br>
<br>
return lnNextNumb<br>
<br>
<br>
<br>
Structure for table: D:\BIDSYS\DBF\NEXTNUMB.DBF<br>
Number of data records: 1 <br>
Date of last update: 02/10/00<br>
Code Page: 1252 <br>
Field Field Name Type Width Dec<br>
1 ID Numeric 10 0 <br>
2 INVOICE Numeric 10 0<br>
3 ORDER Numeric 10 0<br>
4 PURCHASE Numeric 10 0<br>
5 YEAR Numeric 4 0<br>
6 MONTH Numeric 2 0<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top