No,
As I said it's for noneditable grids. For editable use views. If table won't be updated from within grid then it's the solution you need and doesn't require "set filter", "requery" etc. Only grid.refresh is enough.
In case of updatable view, still you don't need "set filter" and despite Rushmore you're right it's slow. In your view have the filter condition as ie:
state = ?m.state
and in txtBox.lostfocus :
m.state = this.value
requery(thisform.mygrid.recordsource)
If views are complex for you then another fast solution is to set a table with states as parent and this table as child linked via state and seek to txtBox.value in states table.
Linkmaster = "state"
Childorder = "state"
RelationalExpression = "state"
=seek(trim(this.value),"states","state")
thisform.mygrid.refresh
Cetin
>Dear sir,
> Thanks for your sample. It is very great for me. But I have some
>questions to ask you about your sample, Can that command update Table ?
>Because after I put that sample, I cannot update any data in Grid.
>So, I must use "set filter" instead that but it 's take so long because
>my table have more than 7000 recs.
> So we would like you to suggest me that which command better than
>"set filter" my codes is :
> mytextbox.valid
> sele customer
> set filter to state=this.value
> mygrid.refresh
>
> Thanks again for your suggestion
> Best regard,
> NO.
>
>>No,
>>If you're talking about noneditable grid, then SQL would be the "recordsource" of grid and "recordsourcetype" would be 4-SQL. Then grid refresh is only needed call to get updated data. You can set it in form.init, grid.init, directly on grid's PEM sheet etc. Be sure you table is already indexed on state (or any other expression contained in where). Pls notice that all SQL is quoted :
>>with thisform.mygrid
>> .recordsourcetype = 4
>> .recordsource = [Sele customer.name, customer.add1,..... ]+;
>> [ where customer.state = Thisform.txtbox1.value ]+;
>> [into cursor crsMyGrid]
>>endwith
>>* txtBox1.lostfocus
>>thisform.mygrid.refresh
You don't even need setting columns in design mode if you don't want special format and columncount. Just drop the grid and size itself.
with thisform.mygrid
>> .columncount = -1
>> .recordsourcetype = 4
>> .recordsource = [Sele customer.name, customer.add1,..... ]+;
>> [ where customer.state = Thisform.txtbox1.value ]+;
>> [into cursor crsMyGrid]
>>endwith
If you put this code in a custom method you could send SQL as a parameter to change info on the fly :)
>>Cetin