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:
00457958
Views:
30
Doru,

Have you tried to use Lookup function instead? It seems to me, that it would be perfectly suited for your situation.

>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.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform