Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching tables in a grid

Status
Not open for further replies.

RoadRunnerOz

Programmer
Aug 22, 2000
128
AU
I have 10 identical tables that I use to store costings for different customers.

I set up a form with an incremental search field and a grid which displays the record found.
The table name is chargeXXX which I open as an alias (master) This initial table is opened in the dataenvironment

I have a dropdown which lists the other identical tables.
In the valid I close master then open a new table as master.
When I close the table & open another table, the grid
goes completely blank. ( I issue thisform.grid1.refresh() )

If I say thisform.grid1.columns=10 and
thisform.grid1.recordsource="master"
the grid is recreated but not in the original format
( header caption, width) and the doubleclick code is gone.

Any ideas on how to switch tables on the fly?

TIA Michael Ouellette
mouellette@compuserve.com
 
Michael,
If I'm understanding this correctly, you have 10 tables called "CHARGExxx". I assume the xxx is the variable part of the table name. Try this:

Instead of opening a table, and aliasing it to "MASTER", place each of the 10 tables in the Data Environment. Make the source of your GRID the table you want to start with. So, in the Data Tab of your grid, make sure the RecordSourceType is set to 1-Alias

Then, set the RecordSource property to your Starting table.

Then, on "The Fly" when you want to change the table associated with the grid (I assume you have some button or something you use to pick the next "table", or some function that does it...)

Issue this:

ThisForm.Grid1.RecordSource = "newtablename"

Grid1 will be whatever the name of your Grid is. If you haven't renamed it, and it's the only one on your form, it will probably still be called Grid1. The "Newtablename" will have to be placed inside Double-Quote marks. Then, issue your:

ThisForm.Grid1.Refresh()

And all should be well.

(I assume you don't have any filter or relationships associated with this. If you do, I would establish them in the DE, not in code, because when you pick the "New" source for your grid, all that will come with it.)
Best Regards,
Scott

Please let me know if this has helped [hammer]
 
Didn't quite work but you set me in the right direction:
with thisform.grid1
* clear recordsource
.RecordSource = ""
Use in master
Use (this.value) order cstart alias master
Thisform.dataenvironment.cursor1.cursorsource=fullpath(dbf("master"))
=CursorSetProp("buffering",2,"master")
* reset record source
.RecordSource = "chgelder"

endwith

By keeping the alias as master I didn't have to change the datasource for all screens.

Thanks heaps...

Thanks Michael Ouellette
mouellette@compuserve.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top