Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search and SET RELATION don't like each other
Message
From
03/05/2001 06:09:24
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00502705
Message ID:
00502911
Views:
15
This message has been marked as a message which has helped to the initial question of the thread.
Hi!

When you search in the child table, you require to move record in the parent table in order to show child record after you restore relation. Yet I see nothing in your code that move record pointer in the parent table (BldMstr) after you find record in the child table. Even if the record you find is the record witrh the same parent record, you should use 'Go recno("BldMstr") in BldMstr' after settiung a relation to apply this relation to the child table. After this, however, record pointer in the child table will move to the first record from the range for parent table, thus you require to remember it before this and than restore to show it properly in the child grid.

As about question how this could be done by another way: this could be done using a lot of different ways. Examples:

SET FILTER instead of relation.
SET KEY instead of relation (will be the best replacement in your case because you already use filter)
Using of the parametrised view. Will be somewhat slower, but is not as important as development time and maintenance - this way requires more time.

HTH.


>Hi everybody,
>
>I have form with two grids. The InitialSelectedAlias of DE is set to BldMstr. I want to search Lender table. In the form Init I set relation:
>
>select BldMstr
>
>set relation to left(nvl(lname,oldvalue),1) into Lender
>
>Lender also has a filter set
>
set filter to status = 'A'
>
>I added two instances of GridHighlighter to highlight records in both grids.
>
>Now, I want to search Lender table and I want to break relations in this case.
>I have this code in form Search method:
>
>********************************************************************
>*  Description.......: LendRev.Search
>*  Calling Samples...: 
>*  Parameter List....: 
>*  Created by........: Nadya Nosonovsky 05/02/2001 02:31:14 PM 
>*  Modified by.......: 
>********************************************************************
>local lnRecno
>lnRecno=recno('Lender')
>select BldMstr
>set relation to && Temprorarily
>thisform.grdLender.SetFocus()
>thisform.DataEnvironment.InitialSelectedAlias="Lender" && Search form uses this property
>dodefault()
>thisform.DataEnvironment.InitialSelectedAlias="BldMstr" && Restore it back
>thisform.lJustSearched=.t.
>
>(I manipulated this InitialSelectedAlias because the search form works with it).
>
>This is the code in AfterRowColChange for BldMstr grid:
>
LPARAMETERS nColIndex
>*!*	if !isnull(lName)
>*!*	   set relation to left(lname,1) into lender
>*!*	else
>*!*	   set relation to
>*!*	   go top in Lender
>*!*	endif
>*!*	dodefault(m.nColIndex)
>local lnRecno
>lnRecno=recno('BldMstr')
>if thisform.lJustSearched
>   set relation to
>endif
>if not thisform.lJustSearched and empty(set('relation'))
>   select BldMstr
>   set relation to left(nvl(lName,substr(OldValue,8)),1) into Lender additive
>endif
>with this
>   .parent.GrdHglt1.Highlight_Row()
>   .statusbartext=space(20)+"Record "+ ;
>	transform(m.lnRecno)+ ;
>	" of "+transform(thisform.NumberOfRecords)+' in '+alias()
>endwith
>thisform.navstand.navupdate()
>thisform.lJustSearched=.f.
>
>Yet, when I performed my search and return to my form, the relations are set and the record, which I just found, is not shown. Could you please advise, what is wrong here?
>
>Thanks in advance.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform