NetTalk Central
		NetTalk Web Server => Web Server - Ask For Help => Topic started by: kevin plummer on August 18, 2007, 04:20:04 AM
		
			
			- 
				Hi All,
 
 I'm using the following to calc the totals of records in a browse on a form to make sure it balances before the user saves the current record. I have the code in the ValidateEnd embed. I can use fetch but any files I try to use Loop Until Access on always fail on the next. The funny thing is I can use fetch to return a single record. What am I doing wrong? This particular form I need to do lots of loops...
 
 L:POC_Amount = 0
 POC:TRAN = p_web.GetSessionValue('POT:TRAN')
 POC:TRN2 = 0
 Set(POC:TRAN_KEY,POC:TRAN_KEY)
 Loop Until Access:POCOST.Next()
 If POC:TRAN ~= p_web.GetSessionValue('POT:TRAN')
 Break
 End
 L:POC_Amount += POC:AMOU
 End
 
- 
				Hi Kevin,
 
 You should not assume that tables have been opened for you.
 I suspect the problem in this case is the missing
 
 Access:POCOST.UseFile() before the call to SET.
 
 Event better would be an explicit
 Acess:POCOST.Open() and Access:POCOST.Close() around the code.
 
 Cheers
 Bruce
 
 
- 
				Hi Bruce,
 
 that did not work. I guess if the file was not open a fetch would not have worked either but fetch works.
 
 are you able to do a simple test on your end or do you want me to send you my app to confirm if it is a bug or I am an idiot?
 
 I'll keep doing some testing on my end and get back to you if it starts working
 
 Code below which does not seem to work. First message returns the correct tran# but code never makes it to message('1')
 
 Cheers,
 
 Kevin
 
 
 !***Balance PO Dist against PO Tran
 If Access:POCOST.Open()
 Message('Error opening POCOST')
 Else
 L:POC_Amount = 0
 POC:TRAN = p_web.GetSessionValue('POT:TRAN')
 message('POC:TRAN=' & POC:TRAN)
 POC:TRN2 = 0
 Set(POC:TRAN_KEY,POC:TRAN_KEY)
 Loop Until Access:POCOST.Next()
 message('1')
 If POC:TRAN ~= p_web.GetSessionValue('POT:TRAN')
 Break
 End
 L:POC_Amount += POC:AMOU
 End
 If Access:POCOST.Close()
 Message('Error closing POCOST')
 End
 End
 !   If L:POC_Amount ~= p_web.GetSessionValue('POT:AMOU') + p_web.GetSessionValue('POT:TaxAmount')
 !     Exit
 !   End
 Message('L:POC_Amount=' & L:POC_Amount)
 
- 
				Hi Kevin,
 
 You gotta lay off those beers on the weekend  ;)
 
 From my note
 >> I suspect the problem in this case is the missing
 >> Access:POCOST.UseFile() before the call to SET.
 
 This is consistent with the FETCH working, because the Fetch does a UseFile internally. The Next also does on internally but it comes AFTER the SET, so the SET is essentially ignored, so the NEXT fails.
 
 Cheers
 Bruce
 
 
 
 
 
- 
				Thanks Bruce that worked - Beers I wish! Maybe more sleep deprivation with the new one awake all night.... at least you confirmed I'm the idiot!