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!

Carry forward values during data entry

Status
Not open for further replies.

cayuga7

IS-IT--Management
Sep 18, 2002
14
0
0
US
I am trying to modify the code below which I inheirited and currently runs on Foxpro 2.6 Dos. New records are entered in the screen displayed by the @say...get statements. I want the values entered in mrec(4) and mrec(5) in one record to carry forward and be displayed during entry of the next record. Any help would be much appreciated. Sorry for the large amount of code. I don't know enough to know which part of it to leave out.

Thank you.

******************************************
use TAG_ITEM in 0 Order 1

sele phy_inv
copy stru to (tempfile)
sele 0
use (tempfile) exclusive alias TMPTAGDBF && Added alias bat 10/17/96
index on TAG_NUM TAG TAG_NUM && created index bat 10/17/96

on key label F2 do unu_tag with mrec(2),muser
**on key label F6 do wip_pop with mrec,muser
**on key label F8 mrec(9)=!mrec(9)
**on key label F9 why_not=!why_not
rr='S'

last_tag = 0
mcnt_by = ''
mchk_by = ''
why_not = .f.

DO while .t.
if !upper(rr)='E'
scatter to mrec blank
mrec(2)=iif(why_not, last_tag,0)
**mrec(7)='EA'
mrec(4)='AB'
mrec(1)=muser
**** Carry forward stk and bin values 9/17/2002
** mrec(4)=mstk
** mrec(5)=mbin
**** End of 9/17/2002 changes Did not work.

endif
clea

@ 4,15 TO 18,75 double
@ 6,20 say 'TAG NUMBER: ' GET mrec(2) pict'9999999' valid FindTag(@mrec) ERROR "" &&bat 10/17/96
@ 8,20 say 'STK: ' GET mrec(4) pict'@!' && added valid function
@ 8,32 say 'BIN/ROW: ' GET mrec(5) pict'@!'
* Skip next line 9/17/2002
* @ 8,54 say 'AREA: ' GET mrec(11) pict'@!'
* End of skip
@ 10,20 say 'ITEM : ' GET mrec(3) pict'@!'
@ 14,20 say 'QUANTITY : ' GET mrec(6) WHEN showitem(mrec(3)) valid mrec(6)<>0.or.alltrim(mrec(3))$'UV'
@ 14,56 say 'UM: ' GET mrec(7) pict'@!'
@ 16,20 say 'STATUS: ' GET mrec(8) pict'@M C,I'
@ 16,45 say 'SLOW/OBSOLETE: ' GET mrec(9) valid mrec(9)$'SO' .or. empt(mrec(9)) ;
pict'@!' mess 'S = Slow O = Obsolete Otherwise Leave Blank'
@ 23,1 say 'F2 TO ENTER UNUSED TAGS BY RANGE U=UNUSED V=VOID'
read

if !empty(mrec(3)) .and. !alltrim(mrec(3))$'UV'
if seek(mrec(3),&quot;itm_mstr&quot;)
mrec(10)=itm_mstr->item_class
if !mrec(7)=itm_mstr->um
@ 14,56 say'UM: ' GET mrec(7) pict'@!' mess itm_mstr->um+;
' IS THE UNIT OF MEASURE FOR THIS ITEM'
read
set mess to
endif
endif
endif
If mrec(8)='I'
set message to
do wip_pop with mrec,muser
else
If !empty(mrec(3)) .and. !alltrim(mrec(3))$'UV'
if !seek(mrec(4)+mrec(5),&quot;loc_mstr&quot;)
@ 8,20 say'STK: ' GET mrec(4) pict'@!' mess ;
'A COMPLETED PART MUST HAVE A VALID LOCATION'
@ 8,32 say'BIN/ROW: ' GET mrec(5) pict'@9'
READ
set mess to
endif
endif
endif

**@23,50 say iif(mrec(9),'** PART MARKED SLOW/OBSOLETE**','') when s/o was logical with f key
rr='S'

rr=secq(rr) && asks save,edit,cancel,quit...returns S,E,C,Q
if upper(rr)='E' .or. upper(rr)='C'
loop
else
if upper(rr)='Q'
if yesno2(&quot;Are you sure you wish to end this BATCH?&quot;)
exit && leave do while loop
endif
else
if (mrec(6)=0 .and. !alltrim(mrec(3))$'UV') .or. empty(mrec(3))
loop
endif
if !seek(mrec(2),&quot;TMPTAGDBF&quot;) &&bat 10/17/96
append blank
endif
mcnt_by=mrec(9)
gather from mrec
last_tag=mrec(2)+1
**** Store value of stk and bin variable to carry forward to next tag 9/17/2002
**** mstk=mrec(4)
**** mbin=mrec(5)
**** End of 9/17/2002 changes Changes did not work 9/17/2002
endif
endif
enddo
 
There are 100's of approaches to your issue. Rather than going through all of your code and telling you specifically how to re-write your program, I will tell you one general approach to resolving the issue.

Like the 100's of possible resolutions there are also 100's of programming styles, so different people will offer different approaches.

Typically I do not do a
SCATTER TO mrec
and then attempt to directly use the Scatter Array values (ex: mrec(4) & mrec(5) ). Instead I generally use memory variables with names which convey meaning to the programmer/reader.

You are merely attempting to save 2 record field values - mrec(4) & mrec(5). These two field values represent two distinct parameters. For my programming style I might call them m.cVal4 & m.cVal5 (for Character values.) or m.nVal4 & m.nVal5 (for Numeric values).

If the last entry will always be to the last record in the table then you merely need to:

Select TMPTAGDBF

* -- Save Original Index * Record No. --
m.OrigIndx = ORDER()
m.nOrigRec = RECNO()

* -- Turn Off Index --
SET ORDER TO

* -- Retrieve Last Record's Data --
GO BOTTOM
m.nVal4 = TMPTAGDBF.<field4name>
m.nVal5 = TMPTAGDBF.<field5name>

* -- Restore Original Index * Return To Orig Record --
SET ORDER TO (m.OrigIndx)
GO m.nOrigRec

And then use the memory variables as needed to &quot;seed&quot; the new entry variables prior to displaying the user entry screen.

You haven't mentioned the timing between entries.
* Will this need to apply to multi-users &quot;simultaneously&quot; entering data?
* Will this need to apply to data entered on Day #1 and then entered next on Day #2?
* Will this only apply to a single user's, consecutive, single data entry session?

The approach that you eventually take will need to be somewhat sensitive to this timing and, consequently, how long this previous record's data needs to be stored - or will it be retrieved each time as fresh &quot;seed&quot; data.

Good Luck,
JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Thanks for your reply. I have been successful in causing the previously entered record's information to appear on screen as I begin to type the next record (entering a new value in tag_num) but as soon as I do that and hit enter, all the other values in the fields on screen go blank, and the record indicator displays EOF. I think I am missing something very basic in the way the values are captured and written to a record. Thanks again for any help.

 
You say that you are entering a new value in TAG_NUM. However you have an Index created on TAG_NUM and you have it Active so when you enter a new value for it, the table is being reorganized accordingly.

Regardless of that, have you run your code through the TRACE Window and watched the values (in the Debug Window) which are being cleared?

If you do that you should be able to find out exactly where the clearing is occuring and what is causing it.

I hope that these general approach suggestions can guide you to resolving your problem, but if you need more help, let me know.

Good Luck,

JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Seems to me the code you have would work if you added the line
store &quot; &quot; to mstk , mbin
before the do while loop
David W. Grewe
Dave@internationalbid.com
 
Thank you to those who responded. I have been able to get it to work after discovering in the code I posted that there was a reference to a function named FINDTAG which was messing me up. The code for the function was buried further down in the program and was not part of the code I posted.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top