Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Createobject('MyForm') from a Form
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Createobject('MyForm') from a Form
Miscellaneous
Thread ID:
00067304
Message ID:
00067304
Views:
96
I have a form with a private DS which includes a command button whose click method is as follows:
nSessionId=ThisForm.DataSessionID
oForm=createobject("AddMilestone")
set datasession to oForm.DataSessionId
use Milepick order milestone
set filter to Milepick.MileId<>999
*oForm.lstMilestones.RowSource="Milepick.milestone"
oForm.lstMilestones.FirstElement=1
oForm.lstMilestones.RowSourceType=6
oForm.lstMilestones.Value=1
oForm.Show()
oForm.Activate()
*read events
nId=oForm.nMileId
use in Milepick
oForm.Release()
set datasession to nSessionID
if nId=0
   =Messagebox("Milestone addition cancelled.",16,"Notice...")
   return 0
endif
dimension AddMile(1,5)
AddMile(1,1)=R6Snc.PWS_ID
AddMile(1,2)=R6Enf1.EnfId
AddMile(1,3)=nId
AddMile(1,4)=R6Enf1.Act_Type
AddMile(1,5)=R6Enf1.Docket_1
Insert into R6Mile from array AddMile
=TableUpdate(.t.,.t.,"R6Mile")
ThisForm.Refresh()
I have tried it with and without the "READ EVENTS", trying to set the RowSource in the listbox causes a "Syntax Error" but commenting it out still allows the RowSource to come from the field I want.

So what's the problem, you ask? One, the code never switches control to the new form (with and without a READ EVENTS, oForm.ACTIVATE(), etc.). I already have 1 READ EVENTS in effect after DO MYMENU.MPR in my startup .PRG. Then when I release the form, I try to go back to the previous forms private DS, and the line "SET DATASESSION TO nSessionID" gives me an "ILLEGAL OPERATION" message, then blows me out of VFP.

I have done this very same thing by pasting the above code in its own .PRG and it works fine. The form I am instantiating is in a class library I developed for this application.
Help? TIA.
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform