Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSession troubles.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00457954
Message ID:
00458025
Views:
24
At the risk of you sending ANOTHER mean-spirited reply...

Rewriting your callme() routine to read as:

PARAMETER tcEmpno

SELECT ALLTRIM(callname) + ' ' + ALLT(empname) AS cTmpName ;
FROM People ;
WHERE tcEmpno = People.empno ;
INTO CURSOR tmpQuery

lcTmpName = IIF(_TALLY>0, tmpQuery.cTmpName, '')

IF Used('tmpQuery')
USE IN tmpquery
ENDIF

RETURN lcTmpName

Preserved not only the record positions of the underlying
tables, but ensured Rushmore optimization for the
query results.

Another way that you might want to try is a LOCAL VIEW.
This would also return a value without moving the record
pointers...

Next time someone replies you a question you might want to
remember that they are trying to HELP you...

Good Luck!!
Bob



>I apologize for the length of the message…
>
>We have a function that receives the employee ID, does a look up on the employee file, and returns the complete name of an employee. We use it in forms and reports. To preserve the environment the function saves the selected area, and the record number upon entry, then restores them before exit. We use GOTO to restore the record pointer.
>
>The problem was that if we call the function while adding a record, GOTO will fail and the current code will move the record pointer to the last record, which is wrong… We can fix it, but we thought that using a new data session for the look up would be a "cleaner" solution. Except, we get all kind of errors, probably because of our lack of understanding of the datasession.
>
>Here is an outline of the code:
>
>
Function CallMe (part of our standard procedure)
>Parameter tcEmpno
>Local lnDS, lnNewDS, lcCallMe
>
><b>lnDS = set('datasession')
>lnNewDS = createobject('session')
>set datasession to lnNewDS.datasessionid</b>
>
>select 0
>use people order empno
>seek tcEmpno
>if found()
>  lcCallMe=iif(empty(termdate),'','*')+trim(callname)+' '+empname
>else
>  lcCallMe=''
>endif
>
><b>release lnNewDS
>set datasession to (lnDS)</b>
>
>return lcCallMe
>
>The errors that we get:
>- Using CallMe() in a form: ‘Cannot access selected table’. Callme() used in the refresh of 2 textboxes. Error pops up while skipping back and forth, it is related to the speed of clicks on the next/previous. Dbf() returns ‘people’ every time the error occurs…
>- Using CallMe() in a report called from a form – Invalid page fault in VFP
>
>The form’s datasession is private, and we do not have anything in the DE of the report.
>
>In both cases the errors do not always occur, but in the second case it occurs almost always.
>
>If we do not use a new data session in CallMe, everything is all right.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform