lowellnelson


I am a neophyte VFP "programmer." Long ago I created a table in FoxPro 2 which included some memo fields, and some code which displayed a stack of windows so that as I scrolled through browse in one window, modify memo in other windows simultaneously displayed the contents of memo fields linked to the recno() of the cursor in the browse window. I am finally trying to reconstruct this in VFP, and when I run my new code (as a prg file) inside VFP everything is fine. My exe file builds without errors, and executes OK within VFP IF the necessary windows have previously been defined and activated and have NOT been cleared. However, if the exe file is called de novo from within VFP (or after clear windows), the window definitions appear to be ignored no matter where I put them: whether the definitions are in the exe file, in the init property of the main form, or in the command button which calls them into view. I cannot understand what I am doing wrong.

I have considered using edit boxes in a form instead of modify memo, but I don't recognize a means of using browse on a form, or how to link the browse cursor [recno()] to the recno() of the edit boxes.

I haven't got to InstallShield yet because of the above issues.

Can anyone help me over this bump
Thanks.



Re: Define window in VFP

dni


1. If you don't "release windows WindowsName" you may not define it again.

2.You may "link the browse cursor" to grid.







Re: Define window in VFP

Tamar E. Granor

This must be the day for BROWSE questions. The right answer to your question is "don't use BROWSE." Use a grid instead, which makes it easy to integrate with a set of edit boxes on a form.

As for linking the grid and the edit boxes, all you'll need to do is call the Refresh method of the form in the grid's AfterRowColChange event.

Tamar





Re: Define window in VFP

CetinBasoz

I always had the thought "from foxpro2.x to VFP it is no more the foxpro you know of". In fox2.x we had used read (valid,cycle) a lot and had trouble coordinating windows (foundation read as I remember). Now just to wet your feet in VFP:

Modi form testForm [enter]

Right click and select dataenvironment

Add a table (from testdata database -ie: employee which has a memo field "notes")

Select table, go to propeties sheet (called PEM sheet) and set buffering to 5 (for now, this lets you freely edit the data and simply close the form w/o saving any changes - remember scatter memvar/gather memvar route in fox2x. Now you don't need it in most cases working in buffer)

Select multiple fields using Ctrl+Click

Drag&drop on form using right mouse button (right button lets you choose from alternatives)

Choose create a grid

Also from that table select few fields again this time including Notes

Again drag&drop with right mouse button

This time select Create multiple controls here

Dblclick on grid

In the code window that opens, select AfterRowColChange in top right combo

Do not touch first line that reads "lparameters nColIndex"

Add:

thisform.refresh

Run the form (right click on form and select from menu, click red ! icon, choose from menu, save and from command window "do form testform" etc ... whichever you prefer).

Now what you have done looks like in Fox2x you created a window, put a coordinated browse and fields on it, generated the spr and ran (yes, you don't need to "generate" anymore and directly run the scx).





Re: Define window in VFP

lowellnelson

Ahhh...yes! Thank you Cetin.

However, this seems to have raised two new problems:
1. My main menu (a form) has a command group, with one of the commands directed to review of data. That command's click method opens another form, which now has a grid displaying my data table, and several edit windows which display the contents of memo fields. This works very well. BUT BEFORE the data form is displayed, after the command button on the menu form is clicked, the data table displays (alone) in a window which still has the menu form title. That window closes with ESC, after which my data form displays as intended. There is no residual browse command, or any other grid which would be responsible for calling the additional undesirable table display.

2. My filters (SET FILTER TO...), which work perfectly well with the browse command, are entirely ignored by the grid, which displays the entire record set in the table.

Can you help me get rid of the unwanted extra display of data, and help me understand how to filter data in a grid

Thanks!




Re: Define window in VFP

Tamar E. Granor

Your extra display of data sounds like you have a query (SQL SELECT) somewhere that isn't being sent to a cursor or other destination.

As for filtering a grid, the right answer depends on how you're populating the grid, but SET FILTER is probably not the way to go.

Tamar




Re: Define window in VFP

lowellnelson

Thank you Tamar

There is no SQL SELECT or any other query, or any command to display data prior to the opening of my data form. The display of data on my data form is completely as intended. The call to the data form results in a BROWSE-like display of the table before the data form is opened.

The grid is populated by setting its recordsource property to the data table. I can very probably use SELECT-SQL, or another method, to generate the data subset, and write it to another table, then use that table to populate my grid on my data form. However, the data on the data form is intended to be editable, back to the original table. If the editing is actually done in a temporary table, then it has to be re-written back to the source table, requiring additional code, and some additional possibilties of coding errors which could corrupt the original table. If a grid does not allow filtered access to the original table, or if you advise me that a temporary table is still the better way, then that's where I'll go. My data tables have only a few thousand records, and the speed of SET FILTER TO does not seem to be a problem for this record set.

Thanks.




Re: Define window in VFP

Tamar E. Granor

I'm not sure why you're getting a BROWSE before your form is there are no queries. You don't have a combobox or listbox based on a query

As for filtering, the best way to do this is with a parameterized view. Then to write the data back to the original table, you just need TableUpdate().

That said, think twice about having users edit data in a grid. It takes a lot of code to make a grid behave as users expect. My preference is to use grids as display only and show data for a single record in a set of controls.

Tamar




Re: Define window in VFP

lowellnelson

Thanks Tamar.

I found the browse problem in a (blush) misplaced piece of code in a load property of a form.