Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Refresh of Grid.
Message
 
À
16/07/2001 04:26:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00530697
Message ID:
00531943
Vues:
14
Hi,

I have some problem with a grid, I tried your first solution but it seems it don't work for me. I create my cursor with a SQL command

SELECT .... INTO CURSOR Myquery
Thisform.Grid1.RecordsourceType = 1
Thisform.Grid1.Recordsource = "myquery"
.
.
.
tmpVar = thisform.grid1.recordsource
thisform.grid1.recordsource=""

Do form frmliaison with "MODIF"

thisform.grid1.recordsource = tmpVar


I tyried also to use RecordsourceType set to 4 and RecordSource with my SQL command, but RecordSource seems to be limited to 255 characters and is not enought for my string.

Any idea will be welcome

>>I have a grid on a form that displays data from a view. When the user wants to look up a different set of data I delete the view and recreate it with the new data.
>>
>> The problem is when I close the view, with USE, the grid names and columns disapear.
>>
>> When The new view is created, based on the same name, the grid is still empty. I have even tried to rename the properties of the grid with the new view and the only thing I get are the column names and no data, eventhough I reset the controlsource properties.
>>
>> I use refresh, and I still get no data. How can I refresh this grid?
>
>William,
>With views instead of deleting, recreating you 'requery' them.
>If for any reason you'd destroy grid's recordsource and recreate it or change it(view,cursor, table, another one with same structure doesn't matter) first set recordsource to 'nothing', prepare your cursor then bind again. ie:
>
>
with thisform.myGrid
> .RecordSource = ''
> * Play with cursor here
> .RecordSource = 'myCursor'
>endwith
Basically this preserves formatting.
>OTOH deleting and creating new view it sounds you never need a view in fact. A view is an SQL definition. You might directly use SQL recordsource (would be readonly by default but sounds like you need it readonly). With SQL recordsource all you need is grid.refresh to 'requery' data. There is a slight catch here however. Any field in where clause should be indexed otherwise you get an empty grid.
>Suppose you have 2 textboxes named txtFirst and txtLast you search for as user enters values in them (firstname and lastname has indexes as upper(firstname),upper(lastname)) :
>
>
*Textboxes' lostfocus
>thisform.myGrid.refresh
>
>*Grid.Init
>with this
> .Recordsourcetype = 4 && SQL
> .Recordsource = ;
> [select * from mytable ]+;
> [ where upper(firstname) = upper(trim(thisform.txtFirst.Value)) ]+;
> [   and upper(lastname) = upper(trim(thisform.txtLast.Value)) ]+;
> [ into cursor crsSearch]
>endwith
Cetin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform