Hi everyone. I've just started using Grids in VFP9.
I am trying to setup a grid which will collect info about an order.
The record source of the grid changes depending on the user. I use the temporary table in the users 'home' folder in order not to conflict with other users.
Here are my questions:
- First, what is the best way to have a temporary file used in my form: Do I add the table to the dataenvironment at runtime Do I issue 'USE' command at form's init Basically I need to open a file which its name is not static but a variable.
- How do I implement something like "Calculated fields" in old browse When the user enters an item #, I need to populate a field which will contain the number of items in stock. I don't want this column to be bound to any table field because it's just a calculated field.
- I've changed one of the columns to have a checkmark instead of a textbox. Does it have to be bound to a table field Basically I want the user to be able to select multiple items in the grid.
Thanks.

Grid objects problems/questions
Giantsonic
You create,populate,index,bind to grid,modify etc. When you close it it's gone. So if you use a cursor do whatever update you would do to your base tables before closing it (again unlike a table its file on disk automatically deleted as soon as you close).
-Calculated fields are not much different from old browse. Write it as a controlsource of a column with parentheses around expression. ie:
thisform.myGrid.myColumnX.Controlsource = "( myCursor.Qty * myCursor.Price )"
thisform.myGrid.myColumnY.Controlsource = ;
"( thisform.MyStockControlClassObject.GetStockBalance( myCursor.ProductID ) )"
You would need adjust columncount of grid to accomodate your new calculated columns. There are many ways to do it. A simple one is to use Grid.AddColumn().
-In theory no but in practice yes (managing unbound data might be a nightmare for the coder-depends). Bind grid columns (like browse) to a table or cursor field. Using a cursor you could simply have such a field like "lSelected L" and make it the controlsource of that column. Since it's simply a field of a cursor it wouldn't harm and would be much easier to handle.
UZ
The Cursor option is not really a solution. The temporary data entry for an invoice needs to exist after files are closed. The user may exit the invoice form after he entered a dozen items, and have it still there.
Basically I nee to open a file which is called tmpinv and it resids in the users OWN directory.
But I think I can manage this now using commands to just add the table to the dataenvironment.
Thanks,
Aleniko
urbs44
Don't. Use a view or just work with buffering instead. In VFP , there's very little reason ever to create temporary tables.
Tamar
Dean Harding
The whole idea of buffering is to make it possible for several people to edit the same table at the same time. Try reading the topic "Buffering Data" in the Help file. The basic idea is that when a table is buffered, the user is working on a temporary copy, and when you issue TableUpdate(), the data is saved from that copy to the original table. You have various ways to handle conflict resolution (multiple users changing the same record).
Tamar
lsberman
If you would like a table then you could create a unique tablename:
lcTableName = forcepath(sys(2015)+'.dbf', sys(2023))
nvenkat
I tried to find a way to Email you directly and cuoldn't find one. If possible, I'd like to contact you directly. My Email address is newal@rugwho.com
Thanks,
Aleniko
ACHawk
I'm not sure how I can do this with buffering My current Foxpro2.6 system uses dbf files that are in every user's home folder in order to collect temporary data entry. For example, if I want to collect items for an invoice, I would use the tmpinv.dbf file that is in the user's \usr\tamar folder. This way a few users can enter invoices simultanously.
Not sure how I would do this in VFP with concepts like DE and buffering
Aleniko