>After I posted my question, I discovered something else about the grid. For example, if the grid has a recordsource of a cursor and the contents of the cursor change, you have to rebuild the grid properties such as columnwidth, column.controlsource, etc. Apparently, when a recordsource for the grid is rebuilt, all methods assigned to the grid disappear as well.
>
>When I first go into the form, all methods work perfectly. But the recordsource, which is a temporary work table created through an SQL statement, is reconstructed through user interaction.
>
>Now that I've found the source of the problem, I think I'm going to have to re-design this thing so my grid's recordsource remains constant throughout the session. In other words, I'm going to have to build a true Parent - Child relationship. Unless someone out there knows how to keep my methods active after the grid's recordsource is changed?
>
>Anyway, thanks for your input.
Terry,
This would occur if recordsource is changed directly or currentcontrol is something else (thus text1 events never fire). Yours is the first as I understand. You have more than one ways to keep it working the way you want :
1)
with thisform.myGrid
.Recordsource = ''
.Recordsource = 'myCursor'
endwith
2)
lcSQL = 'select ... from ...'+ ;
'where somefield = thisform.somecontrol.value into cursor myCursor'
with this
.RecordSourceType = 4
.RecordSource = lcSQL
endwith
Latter works if you have an index for the where part (ie: if it's where Last_name = thiasform.myText.Vaue then you should have an index on last_name). All you need is to call grid.refresh where appropriate say myText.Lostfocus. Of course it's a readonly solution.
3)Grid is based on a view. You only need to requery('myView') and refresh grid.
4)A grid class that sets its headings, controlsources etc via its own methods. You could removeobject current grid, prepare cursor and addobject the class.
5)Saveasclass a grid originating from a vcx, removeobject grid, prepare cursor, addobject saved grid class.
Etc.
Cetin