Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing a free table in Private Data Session
Message
De
02/09/1997 14:08:45
Edward Crawford
City Facilities Management
Glasgow, Royaume Uni
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00047219
Message ID:
00048075
Vues:
32
>>>>Hi Barbara:
>>>>
>>>>I went ahead a did what you said. I think I discovered the problem. When I add a record to a table, I call a method that is not in the form. Here is the method (lcTable is the alias name of the table to add a record to)
>>>>
>>>>LPARAMETERS lcTable
>>>>
>>>>PRIVATE oldOrder
>>>>
>>>>SELECT &lcTable
>>>>oldOrder = ORDER()
>>>>
>>>>SET ORDER TO deleted
>>>>SET DELETED OFF
>>>>SEEK .T.
>>>>IF FOUND()
>>>> RECALL
>>>> SET DELETED ON
>>>>ELSE
>>>> SET DELETED ON
>>>> APPEND BLANK
>>>>ENDIF
>>>>
>>>>SET ORDER TO oldOrder
>>>>
>>>>When I do this I can see the data session changing from my private form DE to the default one, obviously because the method is not in the form. When I return to my form to REPLACE the data, the table is sitting on Record #1, not on the blank record. I don't see any way around this without placing this method in my form.
>>>>
>>>>Ed
>>>
>>>Ed, this method shouldn't change the datasession. However, it DOES seem you have a record pointer problem. Add 2 lines of code:
>>>
>>>.....
>>>  APPEND BLANK
>>>  nRec = recno()
>>
>>Barbara:
>>>ENDIF
>>>
>>>SET ORDER TO oldOrder
>>>go nRec
>>>
>>>This way you force a return to the appended record. In addition, I'd move the SET DELETED ON code to just before the SET ORDER TO oldOrder line. That way you only write it once and it doesn't interfere with setting the correct record.
>>>
>>>HTH
>>>Barbara
>>
>>Hi Barbara:
>>
>>I could probably solve this problem by placing the method in the form, but now it has become intriguing as to what is taking place here. I made the changes that you suggested, but here is what is happening:
>>
>>
>>Before I call this method that is located in a class, not in this form, the ORDER() for the Private Data Session table is set to Actnum. When you look at the Default Data Session it is blank
>>
>>///////////////////////
>>LPARAMETERS lcTable
>>
>>PRIVATE oldOrder
>>
>>SELECT &lcTable
>>oldOrder = ORDER()
>>///////
>>When ORDER() is called it returns "" to oldOrder
>>////
>>SET ORDER TO deleted
>>SET DELETED OFF
>>SEEK .T.
>>IF FOUND()
>> RECALL
>>ELSE
>> APPEND BLANK
>>ENDIF
>>this.RecordHolder = RECNO()
>>////////
>>the correct record number of the added is stored to this property
>>///
>>SET DELETED ON
>>SET ORDER TO oldOrder
>>GOTO this.RecordHolder
>>
>>/////
>>Set ORDER() of course sets the order to "" not Actnum, the GOTO moves the record pointer to the added record in the Default Data Session, but remains on another record in the Private Data session. It's almost like any movement of the record pointer by a method outside of the form effects the Default Data Session, even thought the method was called from within a form with a Private Data Session. What do you think?
>>
>>Ed
>
>Hi Ed,
>I was going to write a long message about passing datasession IDs, when I found Dragan had done all the work for me. I imagine the problem has to do with the method being in a class object, rather than in a procedure file which would have used the datasession of your form.
>
>Let us know if this works,
>Barbara


Passing the DataSessionId to the method worked. Thanks
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform