Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can we input Query in Grid
Message
From
11/01/1999 03:52:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/01/1999 05:00:34
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00173900
Message ID:
00174577
Views:
26
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.
* states and mytable in dataenvironment
* states table has field state
* mytable order is state
* Grid.properties
Linkmaster = "state"
Childorder = "state"
RelationalExpression = "state"
* Textbox.lostfocus
=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 :
* Form.init
>>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
Ç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