Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find - List Dialog
Message
From
06/12/2002 11:16:53
 
General information
Forum:
Visual FoxPro
Category:
CodeMine
Miscellaneous
Thread ID:
00718579
Message ID:
00730345
Views:
14
Mel:

You shouldn't have a problem calling RecordWasMoved going via the CDE? The RecordWasMoved method is part of the codemine cursor object. Using the datamanager and specifying the cursor name simply routes through to the cursor's RecordWasMoved method so, it doesn't make any real difference how you call it.

I have looked at your code and in essence, it should work OK for you. Just a couple of observations. This code shouldn't really be in the click method of a CmdToolActionButtonList. You are binding code into a form's interface (and a button click at that) -- you should be getting away from this Fox 2.x style of coding. The CmdToolActionButtonList calls the form's list method. You could subclass the list method to call another form method that specifically contains your code. Generally, it is good practise to remember that "events call methods". Also, you could optimize your code by using a more up to date syntactical approach.

However, if it works for you as-is, then that is the main thing and your method of calling RecordWasMoved will work.

HTH

>Gary,
>
>>Probably the simplest way to do this is to use the native VFP seek command. Seek on the child table to find your record. If you find it, record its primary key in a variable, note its parent's key value to a variable too.
>
>Then, seek on the parent table. When you have found the parent record, using the parent cursor's CDE object, call its RecordWasMoved method. This will re-sync the datamanager with your changes (pointer relocation) to the parent cursor that it did not know about. Then go back to the child table. Depending on your RI logic, the re-sync on the parent table may have moved the child record again. That's OK. <
>
>Would you give the following code a peek. It was a little different, so I wanted your expert advice as I didn't really know how CodeMine 7 deals with me moving these record pointers, etc.
>
>You mentioned calling the RecordWasMoved() in the CDE, but I had problems doing that so I called the THISFORM.cmDataManager.RecordWasMoved() instead. Also, I called the THISFORM.cmDataManager.FIND() to move the child record - which made it selected as I wanted when the lookup form was closed. It seems to be working perfectly, but I was a little concerned since I used the one in the DM. What you think? This code is in the Click() of the CmdToolActionButtonList that I placed on a form.
>
>LOCAL liHouseID, liPersonID, nSelect, nRecno, lOrgTag, lChildFnd
>
>* Set the cWorkArea and select the special cursor we use to
>* lookup by. Also set special form required properties.
>THISFORM.cWorkArea="PersLook"
>SELECT PersLook
>THISFORM.cNavWorkArea="PersLook"
>* Is special looking up class.
>THISFORM.cListDialogClass = "frmPersLook"
>DODEFAULT()
>* Since frmPersLook is a modal window, following is processed
>* after the frmPersLook is closed.
>
>* Store the items from the lookup cursor we will use to search
>* the parent and child table with.
>m.liHouseID = PersLook.HouseID
>m.liPersonID = PersLook.PersonID
>
>* Reset the form to the defaults.
>THISFORM.cWorkArea="House"
>THISFORM.cNavWorkArea=SPACE(0)
>THISFORM.cListDialogClass = "frmDataListForm"
>* Select parent cursor and find record.
>SELECT House
>m.nSelect = SELECT()
>m.nRecno = RECNO()
>m.lOrgTag = TAG()
>SET ORDER TO TAG HouseID
>SEEK m.liHouseID
>* Return controlling index to original.
>IF !EMPTY(m.lOrgTag)
>	SET ORDER TO TAG m.lOrgTag
>ENDIF
>* Either accept the new Parent location, or reject
>* it if the parent was not found.
>IF FOUND()
>	* Following will update required CodeMine items.
>	THISFORM.cmDataManager.RecordWasMoved('House')
>	* Following finds the correct Child record so that it is selected
>	* when RecordWasMoved is called. It should always be OK to start at first child
>        * record because of RecordWasMoved() above. The .T. parameter
>        * in the following Find() means start search at first child record.
>	m.lChildFnd = THISFORM.cmDataManager.FIND("personid == "+STR(m.liPersonID),"Person",.T.)
>	IF m.lChildFnd = .F.
>		THISFORM.DisplayMessage('The Person record was not found for some reason.')
>	ENDIF
>
>ELSE
>	* Record was not found. This should be impossible - but we will inform user
>	* just in case.
>	THISFORM.DisplayMessage('Sorry the House record was not found. Try another.')
>	IF m.nRecno <= RECCOUNT()
>		GOTO (m.nRecno)  && Restore record pointer.
>	ENDIF
>	RETURN .T.
>ENDIF
>
>* Refresh Form.
>THISFORM.REFRESH()
>
>
>As always, your thoughts are appreciated.
>
>Mel Cummings
-=Gary
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform