>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.
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
But if you use this approach be sure you have an index on field(s) used in where clause.
Cetin