>>I have a read only grid whose recordsource is local view
>>it displays also information from relate tables.
>>
>>When user presses find button, a list of query names is presented.
>>After selection, a create view command is created according to selected query and executed.
>>New view having differeng where condition is created.
>>Records returned by this new view needs to be show in grid.
>>However, after creating new view, grid is empty and relations are lost
>>seting temporarily grid.recordsource='' before create view doesnt help.
>>
>>How to switch views?
>
>
After creating your view are you using it in 0 ? If columns are different also set columncount = -1 before assigning recordsource.
Grid columns are defined in the table and I create it in the fly:
* mygrid.init()
this.addcolumn(this.columncount+1)
with this.Columns[this.columncount]
.removeobject( 'header1' )
.addobject( 'header1', 'myheader' )
.removeobject( 'text1' )
.addobject( 'text1', 'mytext' )
.format = '!'
etc.
So i must re-run this code always again and this slows down program.
Is it possible to change view definition in the fly so that grid columns doesn't need to be re-defined?
>OTOH if that's readonly why are you using views ? You could just use SQL as recordsource :
>RecordSourceType = 4
>RecordSource = "select * from mytable where lSomeExpression"
>
>To change :
>RecordSource = ""
>RecordSource = "select * from mytable where lNewExpression"
>
>Even the expression could be parametric so you don't need to change "recordsource" too. Just supply parameter and refresh the grid.
>
>RecordSource = "select * from mytable where SomeField = thisform.SomeProperty"
>
>thisform.Someproperty = "New Value"
>thisform.myGrid.refresh
I select only primary key and use set relation to display information
in grid. How to use SET RELATION command if grid is based on select statement?
Andrus