Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid afterrowcolumnchange not changing?
Message
From
08/09/2008 11:06:08
 
 
To
08/09/2008 10:57:05
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01345711
Message ID:
01345760
Views:
18
This message has been marked as the solution to the initial question of the thread.
>>>>>>>>>Hi All,
>>>>>>>>>
>>>>>>>>>I have a two grids, one grid controls what is in the other grid, or is suppose to.
>>>>>>>>>
>>>>>>>>>the code I have in the AfterRowColChange method is this:
>>>>>>>>>
>>>>>>>>>LPARAMETERS nColIndex
>>>>>>>>>DODEFAULT()
>>>>>>>>>LOCAL llok, lcclient, laoption(1)
>>>>>>>>>lcclient = ccontact.clientid
>>>>>>>>>laoption[1] = ccontact.contactid  && when I stop it here, the record pointer is still on the first record, not the record I clicked on the grid.
>>>>>>>>>THISFORM.cpageframe1.page1.grid2.RECORDSOURCE = ""
>>>>>>>>>llok = settables(lcclient, THISFORM.DATASESSIONID, "CRACT", @laoption)  && this gets the correct records for the 2nd grid
>>>>>>>>>THISFORM.resetgrids(.T.)  && this sets the grids back to the correct recordsources
>>>>>>>>>SELECT 'crscustmer'
>>>>>>>>>THISFORM.REFRESH()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Any ideas why it is not working for me?
>>>>>>>>>
>>>>>>>>>If I comment out everything, but the 1st two lines, the first grids shows that it is on the other records.
>>>>>>>>>
>>>>>>>>>TIA,
>>>>>>>>>Beth
>>>>>>>>
>>>>>>>>You should set focus to 'child' grid and then return it back to 'parent' grid.
>>>>>>>These are views, so that is not going to do anything - I think.
>>>>>>>My problem is that when I am getting the keys to grab the correct records, the keys are not right (ie Clientid and contactid) Contactid is showing the first record every time, not the record that the 1st grid moved to, like it is suppose to.
>>>>>>>
>>>>>>>Beth
>>>>>>
>>>>>>I use this kind of interface all times, so I know what I am talking about. Besides setting focus you could rethink the way you handle grid recordsources. The best would be tying child grid to a cursor that will be created in Form.Load event and refilled from parent grid ARCC event. This way you don't need to switch recordsource.
>>>>>
>>>>>This is the code in the settable() to get the 2nd grids records:
>>>>>
>>>>>      lcContact = paOthers[1]
>>>>>      IF !EMPTY(lcContact)
>>>>>        SELECT * FROM cract ;
>>>>>          WHERE client_id = lcClient ;
>>>>>          AND contact_id == lcContact ;
>>>>>          ORDER BY date1 INTO CURSOR ccr_act1 nofilter
>>>>>        SELECT 'ccract1'
>>>>>        ZAP
>>>>>        APPEND FROM DBF('ccr_act1')
>>>>>        USE IN SELECT('ccr_act1')
>>>>>      ENDIF
>>>>>
>>>>>I switch between "" and the true recordsource because I am never sure if the cursor is going to break the grid. I can only have one field showing in the grid, and there are 20 fields in the cursor.
>>>>>
>>>>>Beth
>>>>
>>>>Doing ZAP on the cursor (grid.recordsource) does not break the grid as long as you keep focus off. On the contrary, switching recordsource, i.e. emptying it and restoring, may cause multiple problems with grid definitions. Doing that, you might be required to redefine the grid again.
>>>>You may better:
>>>>
>>>>Set safety off
>>>>Zap in ccract1
>>>>Set safety on
>>>>Insert Into ccract1 Select * FROM cract WHERE client .... 
>>>>go top in ccract1 
>>>>Thisform.ChildGrid.setfocus
>>>>Thisform.ParentGrid.setfocus
>>>>
>>>
>>>okay, but the grid definitions is not my problem. My problem at the moment is that I can not get the correct records for the 2nd grid, because contactid is not correct before I even set the 2nd gird recordsource to "". It always stays at the first record for the 1st grid recordsource. It does not move off of it. So my 2nd grid does not change to different records, it always has the same records.
>>
>>Let me try to understand your interface better. Do you move record pointer over parent grid and expect new contents in the child grid? 'Ccract1' is a recordsource for the child grid?
>
>I am not sure about your sentence there. I want to click on a contact in the 1st grid and expect the 2nd grid to show the contents that relate to that contact in the 2nd grid. 'ccract1' is the recordsource for the 2nd grid - child.
>
>Does that make sense?

It definetily does, and I see no problem why can't you use the proposed code, i.e. ZAP, INSERT and SETFOCUS, nothing else. I would give it a try. Most likely, something in your existing code (form.refresh and other unneeded things) returns record pointer to the 1st record of the parent grid.
After all, you can always check if 'ccract1' gets correct records by browsing it after the code (e.g. put BROWSE in Form.RightClick event and check what you get after running the code).
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform