Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pick List Control Source
Message
From
01/01/1998 10:38:40
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
31/12/1997 11:45:32
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00068514
Message ID:
00068772
Views:
33
>>>>Hi Bill,
>>>>
>>>>Use view myview
>>>>for ix=1 to fcount()
>>>>   cField = field(i)
>>>>   index on &cField tag (field(ix))
>>>>endfor
>>>>
>>>>Than set your inGrid cSearchTag(s) accordingly.
>>>
>>>Thanks, I can't figure out how I missed something so simple. Don't suppose you have a recommendation about
>>>where to put this code? Obviously it has to be done after the Requery(), so I'm assuming that I'd just put
>>>it in the same place with the Requery().
>>>
>>>Bill
>>In fact I would suppose to put it in init event of your code or DE.afteropentables so the code would be executed once.
>
>Whoops, did I miss something? I assume that if I do a Requery() because the user has added a new record to the
>base files, that I would have to reindex the view, right? Or does a Requery() automatically rebuild any indexes
>attached to it just like a DBF?
>
>Bill

No you are absolutely right. Sorry. I was so ashamed that I had to find a solution for you so worked about 2 hrs for it and maybe this could help you. Sorry again.

I thougth instead of a view using the tables themselves would be effective since their indexes update automatically. I used the tables again for the picklist and changed the inGrid class a little bit. I don't know if it's legal to modify it. Here is what I did. If it's applicable I will very glad (code still needs some work such as lockscreen - but works as I tested).
I used the tables again this time child being parent and used these second aliases in inGrid Grid.

use Parent in 0 again alias table11
select 0
use Child again alias table21
set rela to relField into table11

recordsource=table21
** 
** InGrid KeySeek method
** 
LOCAL	cHoldAlias,	cHoldTag
*suspend
m.cHoldAlias = ALIAS()
cAliasToSearch = substr(this.parent.controlsource,1,at(".",this.parent.controlsource)-1)
SELECT (THIS.Parent.Parent.RecordSource)
if	SEEK(UPPER(THIS.cSearchString),cAliasToSearch,this.cSeekTag)
	if cAliasToSearch # THIS.Parent.Parent.RecordSource
		=seek(eval(cAliasToSearch+"."+relation(1)),THIS.Parent.Parent.RecordSource,relation(1))
	endif
	IF THIS.nHoldRecord#RECNO(THIS.Parent.Parent.RecordSource)
		THIS.lSeekMode=.T.
	ENDIF
ELSE
	GO THIS.nHoldRecord in (THIS.Parent.Parent.RecordSource)
ENDIF
if cAliasToSearch = THIS.Parent.Parent.RecordSource and !empty(this.cOrderTag)
	set order to tag (this.cOrderTag)
endif	
IF THIS.lSearchPreview
	THIS.Parent.Header1.Caption = THIS.cSearchString
ENDIF
IF USED(m.cHoldAlias)
	SELECT (m.cHoldAlias)
ENDIF
Changing only keyseek method lets the seek be performed based on controlsource and rec pointer moves to related rec in recordsource. But changing the order wouldn't be applicable for the child. So changed the gotfocus this way.
** 
** InGrid Gotfocus
** 
LOCAL	cHoldAlias
IF THIS.lInGridActive
	IF THIS.lSeekMode
		THIS.lSeekMode = .F.
	ELSE
		IF THIS.lSearchPreview
			THIS.cHoldCaption = THIS.Parent.Header1.Caption
		ENDIF
		cAliasToSearch = ;
			substr(this.parent.controlsource,1,at(".",this.parent.controlsource)-1)
		cCurrAlias = THIS.Parent.Parent.RecordSource	
		if cAliasToSearch # cCurrAlias
			dimension aControlSources[this.parent.parent.columncount]
		    for ix=1 to alen(aControlSources,1)
		    	aControlSources[ix] = this.parent.parent.columns(ix).controlsource
		    	this.parent.parent.columns(ix).controlsource = ""
		    endfor
			this.parent.parent.recordsource = ""
			mCrec = recno(cAliasToSearch)
		    select (cCurrAlias)
		    mRel = relation(1)
		    set relation to
		    set order to tag (mRel)
		    select (cAliasToSearch)
		    set relation to &mRel into (cCurrAlias)
		    set skip to (cCurrAlias)
		    goto mCRec in (cAliasToSearch)
		    this.parent.parent.recordsource = cAliasToSearch
		    for ix=1 to alen(aControlSources,1)
		    	this.parent.parent.columns(ix).controlsource = aControlSources[ix]
		    endfor
		    this.setfocus()
		endif
		IF !EMPTY(THIS.cOrderTag)
			m.cHoldAlias = ALIAS()
			SELECT (THIS.Parent.Parent.RecordSource)
			SET ORDER TO THIS.cOrderTag
			SELECT (m.cHoldAlias)
		else
			if !empty(this.cSeekTag)
				m.cHoldAlias = ALIAS()
				SELECT (THIS.Parent.Parent.RecordSource)
				SET ORDER TO tag (THIS.cSeekTag)
				SELECT (m.cHoldAlias)
				this.parent.parent.refresh
			endif	
		ENDIF
	ENDIF
ENDIF
This works as far as I could tested. Hope it helps.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform