What is the scope (intended audience) of this FAQ?

This FAQ was originated because there aren't very many VFP FAQ's out there. Most of the questions are basic in nature, intended to answer the common questions of beginners to VFP. That is not to say that there isn't something out here for more advanced users. In researching for this FAQ, I found a few tips and shortcuts that I had not known before. I hope you do too. This is meant to supplement all other forms of VFP support, not as a substitute.

Please keep in mind that this is not a static document by any means, and we will be correcting and making additions to this on a regular basis.

Questions and comments can be directed towards
Scot Becker.


Who do I yell at if something is incorrect in this FAQ?

This FAQ was compiled by Scot Becker, Co-Founder and Vice President of Vitus Computer Consulting, Inc. (Minneapolis, MN).

Scot has been programming in various languages for the past 12 years, and also works as a DBA, supporting, designing, maintaining, and programming Client-Server systems.

To reach Scot, E-Mail him at
Scot@Vitus.com.

For more information on Vitus Computer Consulting, Inc., see their Web page at http://www.vitus.com.

Scot is always open to suggestions, corrections, and additions to this FAQ.


What is the future of Visual FoxPro?

One of the most common question's in the newsgroups is something like "My boss heard somewhere that MS will not be releasing any more versions of FoxPro and they are abandoning the whole thing. Now, He/She wants me to write our large scale client server application in Access. (This actually happened to me.) What should I tell Him/Her?"

The rumors were fierce, but after the dust cleared we know this:

Visual FoxPro 5.0 will be released in "October".

MS has stated that they intend to bring all of their development tools (VFP, VC++, VB, etc.) into a common development environment currently called Developer's Studio. Developers will be able access the languages they prefer but have a common set of development tools (editors, debuggers, screen designers, etc.).

They have also stated that there will be a version of VFP after v5.0. It is possible that this will be the version that MS merges into Developers Studio.

Microsoft is skipping a version number with VFP. This is to bring it in line with their other development tools. An obvious marketing ploy (just be glad they are making an attempt to market FoxPro!).

MS has stated that they will not be making further enhancements to the xBase portion of the language.

VFP 6.0 is still in its design stage. MS will not comment on features in VFP 6.0


If MS made an Open Letter to the FoxPro Community, what would it say?

They did, it says:

An Open Letter to the FoxPro Community

Recently there has been speculation as to Microsoft's commitment to Visual FoxPro and the FoxPro product line. Some recent articles stated incorrectly that the next release of FoxPro will be the last. Given these inaccuracies and resulting confusion, we want to clarify Microsoft s position on FoxPro today and in the future.

First and foremost, your investment in FoxPro is safe. Microsoft will bring your applications and FoxPro technology forward. Currently, Microsoft just put the finishing touches on Visual FoxPro for the Power Macintosh. The product team is also hard at work on the next version, Visual FoxPro 5.0 for Windows. After version 5.0 ships, Microsoft will start working on the next release of Visual FoxPro. Visual FoxPro will remain a great tool for high-end database development today and in the future.

Visual FoxPro 3.0 for the Power Macintosh has been released to manufacturing. This product has full cross-platform compatibility with Visual FoxPro 3.0 for Windows. This release brings object-oriented programming to the Power Macintosh while continuing to be a performance leader. All of the great technology that users applaud in Visual FoxPro for Windows is now available on the Power Macintosh.

Visual FoxPro 5.0 for Windows will be released in Fall 1996. This version will have powerful connectivity features, the ability to create OLE automation servers, full support for ActiveX controls, an enhanced development environment, a smaller footprint, and greater performance. After Visual FoxPro 5.0 ships this fall, the FoxPro team, in conjunction with our other development tool groups, will be working on better integration of our development tools. The integration will allow users to leverage common technologies across all of our development tools. An example of this will be the use of the FoxPro engine technology in other Microsoft development products such as Visual Basic. This is a strategy that we have talked about and outlined for the past several years. You will start to see this strategy come together in upcoming releases of Microsoft development products.

In addition to the integration work, the FoxPro team will be working on common object technology. This technology will allow Visual FoxPro developers to create ActiveX objects that can be used in any ActiveX-enabled container. Specifically, this will enable users existing Visual FoxPro investments to be encapsulated and leveraged going forward.

To summarize, we have been developing the future product plans for our development tool products. In parallel, there have been some incidents that have caused confusion in the FoxPro community. Given all of this, we feel it is important to share with our FoxPro users some of our specific future product plans. Every user should know first and foremost that the investment you have made and continue to make in Visual FoxPro will be supported and brought forward. We believe that the combination of ActiveX control and server creation along with integration of our tool set will create the best possible development environment for application developers. Visual FoxPro and the FoxPro development team will play a central part in making this vision come true.

Tod Nielsen - Visual FoxPro General Manager
Bob Muglia- Vice President Internet Platform and Tools Division


Where can I get support for VFP?

There are many places to get support for Visual Foxpro. The most powerful area is the internet (big suprise, where are you reading this from?) I would recommend checking them all out and choosing the ones that suit your needs. Obviously, Michel Fournier (Fournier Transformation) has done a lot of work to meet this demand with The Visual FoxPro Yellow Pages, The Universal Thread, and with his collaborations in the Virtual FoxPro User Group (VFUG). These sources are excellent (in my opinion) and are definitely worth consulting.

In addition there are newsgroups (both MS and non-MS), the CIS forums (now privately maintained after MS pulled out), and web sites. There are many to choose from. Most of them are little more than links to other internet sources, but some cater to certain areas and users that you may find helpful. In addition, Microsoft's web pages are also a good source for information. They provide a Knowledge base, which has solutions to countless problems and bugs, a developers forum, a Win32 development forum, patches and downloads, etc. They are an essential source of VFP information.

(Please note: there are many good private web pages out there, but I have refrained from mentioning them here as that is not the point of this FAQ. You can get a good start by checking out the internet resources listed in the VFP page from there, you will be able to find many more sources, it is worth the time to investigate them.)

There are many FoxPro and Visual FoxPro publications to which you can subscribe such as FoxTalk (Pinnacle Publishing) FoxPro Advisor (Advisor Publications) and Inside Visual FoxPro (the Cobb Group).

You can also contact MS Support. Their phone number is (206) 635-7191 from 6 AM to 6 PM (Pacific Time) in the US. In Canada, call (905) 568-3503 from 8 AM to 8 PM Eastern time. You now have 2 free "incidents" for each copy of VFP that you own, and other support options are available after that, the costs vary. You should have the following information available when you call: The version number you are using, hardware configuration, the exact wording of any error messages, a description of what happened and what you were doing, and a description of how you tried to solve the problem.

Also, MS has their Developers Network program and the TechNet CD-Rom's which can be invaluable (especially if you are interfacing with other MS products). The main drawback is the cost. But if you have the cash and the need, they are recommended (besides if you subscribe at $1000+ you might get a T-shirt or something).


Why don't the controls on my pageframes operate properly when I use the TxtBtns navigation class?

The standard VFP 3.0 TxtBtns class do not recognize pageframes and pages. MS has updated the Wizards. They are available on Compuserve's Microsoft Library (GO MSL) and on Microsoft's WWW Home Page. This has also been fixed with version 3.0b.


How do I return a value from a form?

You can return a value from any modal form by putting a RETURN in the unload event of the form.


How do I add a property or method to a Form in the Form Designer?

With either the form designer window or the Properties/Events/Methods (PEM) window active, select Form from the menu. The first two selections are New Property and New Method. Select the appropriate one and fill in the dialog box. The property will appear at the bottom of the All and Other tabs of the PEM window.


I've moved one of my toolbars or one of my design windows off of the screen, how do I get it back?

The location settings are stored in the FOXUSER.DBF table located in the main VFP directory. If you delete or modify this file all your toolbars and windows will revert to their default locations or whatever values you set for them.

Or, use the Arrange All selection from the Window menu pad.


How do I get rid of the 'Invalid User Input' message when returning .F. from a Valid Event?

Return 0 instead of .F. When you return a number from the Valid event, you are setting how many controls in the Tab Order you want to move ahead (or back if you return a negative number).



Why do things never work quite right under Windows 3.1x?

Under Win32s, VFP has been unstable. Win32s is a translation layer for 32 bit commands, converting (A.K.A. "Thunking", the very word is a good indication to stay away!) them into their 16 bit equivalents. Win32s is slower, requires more resources and requires a 10 MB swap file, without which VFP is very unstable. AVOID IT IF YOU CAN!

Note: I'm told that the latest version of Win32s is much more stable than previous versions. If you are stuck with 16-bit platforms, try downloading the latest drivers from the MS site.



What Are the differences between Modal and Modeless forms (windows)?

Modal windows are generally used to handle operations such as reporting an error, or asking the user to confirm an action, etc. Menus are disabled when in a modal window. Modal forms also provide an application 'Wait State' if needed.

Modeless forms offer more flexibility, allowing the user to switch from form to form as well as allowing access to the menus.



My compiled application started, flashed briefly, and then quit; What happened?

You need to create a 'wait state' in your application. You can use the READ EVENTS command to create the wait state. In order to clear the wait state, you can use CLEAR EVENTS command.

If you have a single screen, you can set the form's WindowState to Modal. This also provides a wait state, but doesn't allow you to use menus. When the modal form gets released, the wait state ends and the application exits to the operating system.



When I create a form, my environment variables (changed with SET) revert to thier default values.

You form has a private data session. Many "SET" commands are scoped to the current data session only. When you have a private data, you must re-establish those settings. One way to do this is to create a custom class which sets your environment settings and then reverts them to their original values in its destroy event.



If I change pages in my pageframe, the other page still has the old record in the fields. Why?

You need to have code in the Activate() of each of your pages to make sure your display will be current. If you did a THISFORM.Refresh() somewhere, VFP will only refresh the active page of the PageFrame. Try THIS.Refresh() in the Activate() of each page.



My form doesn't display everything when I run it. It shows up, but none of the controls are visible.

Try setting the LockScreen property to .F.



I have an object on a form which I can't see to select or modify.

Open the PEM sheet. There is a dropdown list which you can use to select the object you want to edit. Once it is highlighted on the dropdown list, you can make any changes to the object. To adjust it with the mouse (or to actually see the object) in the form designer, Select Format from the menu and then select Bring to Front.



How do I copy a class from one class library to another?

In the professional edition, you can open two instances of the class browser, and drag the icon underneath the Type dropdown list box onto the second instance of the class browser. Be sure to drop it on another area of the class browser target form. You should see a copy cursor icon (arrow with a plus sign) before you drop the dragging object.

If you are using the Project Manager and you have both class libraries in the project, you drag the class from one library to another. This won't work if the destination library already has a class with the same name, and the library must already exist.

There is a VFP command which allows you to copy a class from one library to another. Try: ADD CLASS MyTextBox OF MYLIB1.VCX TO MYLIB2.VCX. This also will fail if there is another class of the same name in MyLib2, but you can add the OVERWRITE clause and the class will be replaced.



How do I get to an object inside a container without having to use the PEM window?

Right click on the object. From the popup menu, select Edit. If you are working with a grid, you will have to select the column in which the object is located and then use the PEM sheet to select the specific object you want to edit. If you want to select a header class or other object inside a column, you will have to use the PEM sheet.



How can I pass an array to a form as a parameter?

Arrays in FoxPro must be passed by reference. SET UDFPARMS determines parameters passing. Parameters are passed by reference by default, when you call a procedure or form using DO...WITH.

DIMENSION array[10]
DO FORM Form1 WITH array
Parameters are passed by value in function calls and methods. In this case, you must force the parameter to pass by reference. Precede it with an "@"
DIMENSION array[10]
MyForm = CREATEOBJECT("Form1", @myarray)



How do I get rid of the Microsoft Visual FoxPro title?

In the CONFIG.FPW file, add "TITLE = Access Is For Sissies". (Note: omit the quotes)

You can also do this by :

_SCREEN.Caption = "Access Is For Sissies"



How do I get rid of the VFP splash screen?

In your Program line of your shortcut or icon, add "-T" (without quotes) after VFP.EXE.



Under Win95, the upper left corner of all screens default to the Fox icon. Can I replace it?

In your startup program, add this line:

_Screen.Icon = "Vitus.ICO"


In the Load event of your forms, add this line:
THISFORM.Icon ="Vitus.ICO"
or manually set it in the PEM sheet of the form designer.



How do I hide the main Visual FoxPro screen and menu?

You can give the _SCREEN object a left value of something wacked like -5000. If you wish to see your forms, be sure to set the DeskTop Property to .F.. Keep in mind that you will lose the use of Toolbars because they must reside in the main window.

If you are running this app from Fox, open the FOXPRO.INI file, and change the ROW= and COLUMN= to something like 5000. Note this will only work when running a program or .APP file from inside VFP; A FoxPro .EXE does not read the FOXPRO.INI file.



How do I remove a Form's title bar?

Set the Caption property to ""
Set the ControlBox property to .F.
Set the MaxButton property to .F.
Set the MinButton property to .F.
Set the Movable property to .F.



What is the firing order of Events?

Check out "Visual FoxPro Event Sequence" in the help file.

Also, in the VFP\SAMPLES\CONTROLS\EVENTS directory there is an application called EVENTS.APP which demonstrates the firing order of events for various objects.



How do I test if a variable exists?

Use the TYPE() function: to test for the variable's existence.

IF TYPE("Var")
	=MessageBox("It exists",0,"")
ENDIF
Or you can check if
TYPE("Var") = "U"



What is the maximum size table Visual FoxPro can handle?

The maximum file size for Visual FoxPro is 2GB. It's a FoxPro limitation that (hopefully) will be removed in a future version. An alternative for large applications is use VFP as the front end to retrieve the data being stored on a backend capable of supporting the larger file size.

For other system limits, see the help file.



When I run an EXE, the system menu always appears before my menu is run.

Put SYSMENU=OFF in your Config.FPW file.



I can't set focus to an object from another object's Valid event.

The SETFOCUS() method does not work from the Valid event. Try using the LostFocus event instead.



How do I get the Form Designer to use a form class that I create for its default form?

Select the Options pad from the Tools menu. From the pageframe that comes up, select the Forms page. Near the bottom of that page is a check box for your form class. Check that box and select your form class from the dialog that comes up. You can press the button with "..." (ellipses) next to the box which shows your form class to change your selection. Make sure you press the Save as Default button before you exit to make your changes permanent.



An error message appears which says 'Cannot quit Visual Foxpro'.

Check out the ON SHUTDOWN interrupt.



What do I need to worry about when I upgrade from 3.0 to 3.0b?

Completely uninstall of Visual FoxPro (use setup and it will ask if you want to remove current installation) before installing 3.0b.

If you are using Windows 3.1, you must do the Win32's removal following the instructions in the README file on the 3.0b disk.

If you have used the setup wizard to create distribution disk none of the above will get rid of the files maintained in the DISTRIB and COMPRESS directories created with this utility. You have to delete them.

If the user is running just application and not the full version of VFP with Win32s, then all you need to do is replace the VFP300.ESL and FOXUT16.DLL files located in the WINDOWS\SYSTEM directory. Your application should run fine. If you are using Win32s, follow the instructions for removing Win32s, then recreate your installation disks and reinstall the application.



How do I keep a form from running while it's starting up?

You prevent instantiation of a form by RETURNing .F. from the INIT() method. This actually works with all objects.

Note: not only will RETURNing .F. from the Init() of any object prevent it from instantiating, it will also prevent its parent container (if any) from instantiating.



When will timers not fire?

They will not fire if you have a menu dropped, if a Windows MESSAGEBOX() is active, when the user is resizing or dragging a form, and when the user is using a scrollbar.



How can I leave a grid without using the mouse?

You can press CTRL+TAB to move to the next control or SHIFT+CTRL+TAB to move to the previous control.



What is the scope of an Include file?

When you include a file in a form using the Form/Include File menu item, all objects of the form have access to the contents.

If you explicitly #include it in a method, only that method has access to it. In the class designer, the same rules apply.



What other versions of Visual FoxPro 3.0 are there?

Microsoft says :
"Version 3.0a is a Double-Byte Character Set (DBCS) enabled release for the Far East only. Visual FoxPro 3.0b is a worldwide release that supports DBCS and is also the version that synchronizes Visual FoxPro with the final releases of Win32s and Open Database Connectivity (ODBC)."

What they don't mention is that 3.0b fixed many bugs with 3.0. Information on those bugs and fixes can be found in the MS knowledge Base.



Does Visual FoxPro support .VBX files?

No, but, it supports OLE (a.k.a. "ActiveX") controls.



Why doesn't my MEMLIMIT setting work?

Visual FoxPro allocates memory dynamically on all supported platforms. Therefore, the MEMLIMIT setting is no longer required.



What are the differences between the Professional and Standard Editions of Visual FoxPro?

The Professional Edition of Visual FoxPro allows you to create, compile, and distribute royalty-free applications. In addition, the following features and tools are available only in the Professional Edition:



I've placed a check box in my grid, but it only appears in the currently selected row.

Set the Sparse property to .F.

Contributed by
Alex Nobre



How do I use macro expansions?

You can use & to interpret and execute instructions built 'on the fly'.

lc='? DATE()'
&lc



How do I select duplicate records from a table?

SELECT * ;
FROM table A ;
WHERE EXISTS ;
(SELECT * ;
	FROM table B ;
	WHERE B.key = A.key;
	GROUP BY key ;
	HAVING COUNT(*) > 1 ) ;
ORDER BY fieldlist
or
SELECT * ;
FROM table ;
WHERE key IN ;
	( SELECT key ;
	FROM table ;
	GROUP BY key  ;
	HAVING count(*) > 1) ;
ORDER BY fieldlist



What is the difference between the DataSource property and the ControlSource property?

The DataSource property affects ODBC views stored in a database (.DBC). It contains a reference to the name of the data file to which ODBC is connecting, and must point to a valid data source defined through the ODBC administrator. You manipulate the DataSource property with the SQLSETPROP( ) function, and view its settings with the SQLGETPROP( ) function.

The ControlSource property is used to determine the source of data to which an object is bound. Objects that have a ControlSource property include the CheckBox, Column, ComboBox, CommandGroup, EditBox, ListBox, OLE Bound Control, OptionButton, OptionGroup, Spinner, and TextBox controls.



My combo box is displaying only one row when I dimensioned the array in the Init event of my form.

You created an array in the form's Init event with no rows or one row. When the form is created , the Init event of the combo box occurs before the Init event of the form, and the combo box contains only one row of information. To fix this, add the following line of code immediately after the SELECT - SQL statement that creates the array in the form's Init event:

THISFORM.ComboBox1.RowSource = THISFORM.ComboBox1.RowSource



When my cursor is updated by a SELECT - SQL INTO CURSOR command, my grid doesn't refresh.

"This behavior is by design." Because the SELECT - SQL statement is re-executed with the same cursor name in the grid's RecordSource property, the original cursor is discarded when the new cursor can be created. When that happens, the grid's RecordSource property is cleared and reset and a new grid is created that does not load the data from the cursor. To refresh the grid, set the grid's RecordSource property to itself :

THISFORM.Grid1.RecordSource=THISFORM.Grid1.RecordSource



How do I hide standard and custom toolbars?

Use HIDE WINDOW to hide toolbars. A toolbar can be displayed with SHOW WINDOW.



I have the Standard Edition of Visual FoxPro. Where can I get a copy of the Language Reference?

The Standard Edition includes the most complete and up-to-date version of the Language Reference -- online, in Help. The printed version of the Language Reference does not contain last-minute updates, any SYS() functions, or backwards-compatible commands. If you need a printed copy, you can upgrade to the Professional Edition, or you can order a printed Language Reference for $29.95: call 1-800-360-7561 and ask for part number 61846.



How do I make small icons with Visual FoxPro (ImagEdit)?

Windows 95 can display small icons in the Explorer and the Start menu. You can use ImagEdit to create small icons for your Visual FoxPro applications running under Windows 95. (ImagEdit is included in the Professional Edition of Visual FoxPro.)

Small icons are created by specifying the Small Icon 16-color 16x16 option when creating a new icon in ImagEdit. If this option is not available when you create a new icon, add the following lines to the IMAGEDIT.INI file located in your Windows directory:

[ImagEdit.Icon]
Small Icon=16,16,16



How do I navigate appended records in table buffers?

To move the record pointer to appended records in a table buffer, use the GO command with a negative value. The RECNO( ) function returns sequential ascending negative numbers on records appended in a table buffer.



How do I (programatically) copy to the clipboard?

See _ClipText in the help file.



How do I keep my timers from firing when I am debugging?

Put this code in the Timer() event, and then to enable your timer thereafter, just enter _Screen.ActiveForm.MyTimer.Enabled=.T. in the Command window.

IF WVISIBLE("Trace")
	THIS.Enabled=.F.
ENDIF



How do I play .WAV files?

Aside from 3rd party products and API calls, the easiest way to play a .WAV is :

SET BELL TO "c:\sound.wav",1
??CHR(7)
SET BELL TO



How do I set multiple procedure or class files?

Use the ADDITIVE clause:

SET PROCEDURE TO proc.prg ADDITIVE
SET LIBRARY TO class.vcx ADDITIVE



Why should I use locate instead of seek when a filter is set?

SEEK is usually the fastest way to find a single record when the field you're searching on is indexed. However, when a filter condition is in effect, SEEK can be very slow. The reason is that SEEK will find the first record meeting your search criteria. FoxPro then moves through the table sequentially to find a record that matches your criteria, and matches the filter condition.

Unlike SEEK, LOCATE is Rushmore optimizable. LOCATE FOR CustId=m.CustId is usually much faster than SEEK m.CustId when an optimizable filter is in effect.

The same problem occurs with GO TOP and GO BOTTOM. Use LOCATE with no clauses to GO TOP. It will get you to the first record that meets the filter condition. To GO BOTTOM, set your current index tag DESCENDING, then LOCATE, then set the tag back to ASCENDING.



How do I reset properties and methods to their default values?

You can right click any property in the Property Sheet and return values to their default state. This is especially useful when you want to reset an object's attribute to allow that object to exhibit the Parent Class's behavior. For example, if you're using a Label class definition that has FontBold = .T., but this instance of the object has FontBold = .F., you can recall the Class Definition's default simply by right-clicking and choosing "Reset to Default".

This behavior also applies to the Methods in the Property Sheet. You can remove all method code from the method listing by right- clicking. This is a handy way to reset the current object instance to run the Class Definition's method code. If you accidentally reset your method code to default, you can get it back by exiting your Form Designer session and selecting "No" when prompted "Do you want to save changes to Form Designer ..."



How do I execute both the default parent event/method code as well as some additional code?

You can override Parent Class Method code by entering specific code in the associated method of the object instance. FoxPro interprets any characters in the method code as executable code which will override parent class methods, including spaces and comments.

If you want to add comments to method code and retain the Parent Class' method code inheritance, use the Scope resolution operator (::) to explicitly call the Parent Class' code. The click event procedure for a Command Button might look like this, for example:

&& Comments
MyExitButton::Click
&& any additional code (not included in default click event) here, if desired



How do I coordinate enabling and disabling toolbar buttons and their corresponding menu choices?

A straightforward way to coordinate enabling or disabling menu choices in conjunction with Toolbar buttons is to use the Enabled property in the Set Skip clause of the menu. For example, say you have a toolbar called oToolbar with an add CommandButton named cmdAdd, and a Record menu with an Add option. By setting the Set Skip clause of the Add option to "oToolBar.cmdAdd.Enabled = .F." or "!oToolBar.cmdAdd.Enabled" the Add menu option is only available when oToolBar.cmdAdd is Enabled.

Remember - the Set Skip disables the menu choice when it evaluates to .T., which is why the NOT operator (!) or "= .F." is required.



What is an easy way to set the same property in multiple objects at the same time?

Use the SetAll method

For example, you decide you want the font for all the header captions in a grid to all be 12 point Arial. Place this in the Init event of the grid:

THIS.SETALL("FontName","Arial","Header")



Do I have to always type long object hierarchy lists?

Nope. You can use variable substitution

These 2 methods are equivalent:


Thisform.pageframe.page1.container.object.caption = "This really sucks to type frequently"
Thisform.pageframe.page1.container.object.left = 10
Thisform.pageframe.page1.container.object.top = 50
temp = Thisform.pageframe.page1.container.object
temp.caption = "This is better if you have many statements"
temp.left = 10
temp.top = 50
Another way is to use the WITH command:
WITH Thisform.pageframe.page1.container.object
	.caption = "This is actually more optimized, and easier to type"
	.left = 10
	.top = 50
ENDWITH



How can I navigate the PEM sheet quickly?

The Ctrl+Alt+key short-cut helps make navigating in the Property quick and easy. For example, pressing Ctrl+Alt+C while the form object is selected in the Property sheet will take you to the Caption property.



How do I see what got written to the VFP desktop when I have all those windows open?

Pressing ALT+CTRL+SHIFT will hide all open windows within the VFP desktop until you release the keys.



Can I create text reports?

You sure can. Check out the ASCII clause of REPORT FORM.



How do I reverse the action of something in the sizing toolbar?

Hold down CTRL while you click on it.



How can I move objects in a form more precisely?

You can move an object one pixel at a time by using the arrow keys or by holding down CTRL while dragging it.



Does Drag and Drop work in most windows?

Yes, one of the cooler places (IMHO, anyway) to see this is in the Command window. You can drag code you typed in there to any code screen.



When manipulating a page property, I get an error saying "Property xyz not found".

You probably are missing the reference to the container object of the page frame itself:

ThisForm.Page1.xyz = 1

Should be:

ThisForm.Pageframe.Page1.xyz = 1


How do I append text to a memo field?
lcMemo = 'Append this string'
REPLACE Table.MemoField WITH lcMemo ADDITIVE


Why doesn't my newly compiled VFP 5.0 .exe work under Win32s?

VFP 5.0 will only run under and compile executables for the Win32 Operating System. There is no support for 16-bit Operating Systems or Win32s.



What's new in VFP 5.0?

Many, many things. New features, faster environment, smaller memory signature, bug fixes, and a better development environment to name a few out the Microsoft WWW site for more details.



What is an Outer Join?

Even if you are a novice FoxPro developer you probably heard the magic words "OUTER JOINs" and the fact that FoxPro/Visual FoxPro doesn't support them, well, with version 5.0 OUTER JOINs finally made it into the language. But what are these OUTER JOINs anyway?

Ok, SELECT - SQL is a very poweful command, you can use it to get a subset of records from a single table, you can also use it to get a subset from more than one table, this is where JOINs come into play.

There are 4 ways to JOIN 2 table to help me explain them I'll use the following data

                 Key                Name
Table A:         A                  Arnon
                 B                  Tom
                 C                  Michel
                 D                  Scot
                 E                  Paul

                 Fname
Table B:         A                  Gal-Oz
                 B                  O'Hare
                 C                  Fournier
                 D                  Becker
                 F                  Elliot 
SELECT A.Key,A.Name,B.FNAME from A xxx JOIN B ON A.Key==B.Key ORDER BY 1 where xxx - will be the JOIN we will use

INNER JOIN - this is the way foxpro has been doing it joins up until Visual FoxPRo 5.0 and even in 5.0 this is the default way when you use INNER JOIN records that have a matching record (based on the join condition) in our example the end result will be

                    A Arnon   Gal-Oz
                    B Tom     O'Hare
                    C Michel  Fournier
                    D Scot    Becker
LEFT OUTER JOIN - with this you will have all the records from the first table (left table) and only matching records from the second table. In our example the end result will be
                    A Arnon   Gal-Oz
                    B Tom     O'Hare
                    C Michel  Fournier
                    D Scot    Becker
                    E Paul 
RIGHT OUTER JOIN - this is just the opposite of LEFT OUTER JOIN - that is, you will get all the records from the second (right) table and only matching record from the first (left) table. In our example the end result will be
                    A Arnon   Gal-Oz
                    B Tom     O'Hare
                    C Michel  Fournier
                    D Scot    Becker
                              Elliot
FULL OUTER JOIN - as its name implies this will have the non-matched and matched records from both table. In our example the end result will be
                    A Arnon   Gal-Oz
                    B Tom     O'Hare
                    C Michel  Fournier
                    D Scot    Becker
                    E Paul 
                              Elliot  
Note that we did not get a key for "ELLIOT" in the RIGHT and FULL JOINs this is because out orifinal SELECT statement is SELECT A.Key and A does not have a key for Elliot to solve this in the RIGHT JOIN all we have to do is change the SELECT to B.Key... instead, but this will not work in the case of the FULL join - because then we will not have a key for "PAUL", if we do a FULL JOIN we need to use a IIF fro the fields in the JOIN condition (if we want them as part of the result) in out example it will look like:
SELECT IIF(A.Key#" ",A.Key,B.Key),A.name,B.fname  FROM A FULL JOIN B ON A.Key==B.Key
And natuarally u can play with this and with FoxPro ability for sub-queries to get only nomatching record etc. etc.



How do I hide the Visual FoxPro 5.0 desktop when my application's .EXE file starts?

Put the following line in the CONFIG.FPW configuration file:

SCREEN=OFF

Note: If you do not need to provide the CONFIG.FPW as a separate file-- that is, you will not need to be making any changes to it after building the .EXE--you can add the CONFIG.FPW file to the project, making sure it is marked as included, and it will be built it as part of the .EXE.



How do I create a top-level form with a top-level menu?

To create a top-level form, set the form's ShowWindow property to 2-As Top Level Form. To create a top-level menu, open the Menu Designer. From the View menu, choose General Options, then set the Top-Level Form option. To place the top-level menu in the top-level form, put the following code in the Init event of the form:

DO (menu name.mpr) with THIS


For my Visual FoxPro 3.0 forms in Visual FoxPro 5.0, the fonts are smaller and no longer bold.

To enable you to more easily make forms that comply with the Windows 95 standard, several default property settings for controls were changed, including FontSize, FontBold, and ColorSource. If these were set to default values under Visual FoxPro 3.0, they will remain defaults under Visual FoxPro 5.0. However, because the defaults are different, text will be displayed differently.

If you want to have your forms appear as they did in Visual FoxPro 3.0, convert them as part of a project. Then when you open the Visual FoxPro 3.0 project in Visual FoxPro 5.0, check the Retain Visual FoxPro 3.0 Default Property Values check box in the Converter.



The Application Wizard does not appear when I select Wizards from the Tools menu. How do I run it?

To run the Application Wizard, choose Wizards from the Tools menu and then choose All from the submenu. This opens the Wizard Selection dialog box from which you can select the Application Wizard.



How do I hide specific columns in a combo box and display others?
Microsoft says: "The easiest way to hide specific columns in a combo box is with the Combo Box Builder. Drag the columns to the desired width in the Layout tab of the Combo Box Builder. To hide specific columns in a combo box programatically, set the ColumnWidth property to 0 for the columns. In the following program code, Columns 1 and 2 are hidden, and Column 3 has a width of 100 pixels:

THISFORM.ComboBox1.ColumnWidths = 0,0,100"


What is the difference between table buffering and referential integrity?

Microsoft says: "Row and table buffering can be used to directly update tables and records in a multiuser environment. This eliminates the need to place the data from a record into system variables, edit the system variables, check to see if the record has changed, and then write the changes to the record. For more information, see Chapter 17, "Programming for Shared Access," in the Developer's Guide.

In a relational database, referential integrity consists of the rules that govern the relationships between the primary and foreign keys of different tables. Referential integrity guarantees that all foreign keys match a value in the corresponding primary key field.

In addition to allowing Visual FoxPro to enforce rules that govern referential integrity, you can create stored procedures that perform specific actions when a record in a table is updated, deleted, or inserted. The Referential Integrity Builder can create stored procedures for each Update, Delete, or Insert trigger. The Visual FoxPro trigger types are listed below and the stored procedures available for each are listed in parentheses after the trigger type.

The names of stored procedures are inserted into each trigger in the Table Properties dialog box of the Table Designer. Triggers are typically stored as a part of the database's stored procedures (as the Referential Integrity Builder does), but can also be an external program or procedure. Triggers can be created programmatically with CREATE TRIGGER, or by adding a stored procedure to the database and referencing the stored procedure in the appropriate trigger in the Table Properties dialog box of the Table Designer.

Although triggers are typically used to implement (by using the Referential Integrity Builder) Cascade or Restrict capabilities on Update and Delete events, or Restrict capabilities on Insert events, these triggers can also be used to call stored procedures that perform actions unrelated to referential integrity. For example, an Update trigger could execute a stored procedure that sends an email message to another department to notify others of a change.

Referential integrity and buffering interact in the following way. Record-level event code is executed after a record is inserted, updated, or deleted. Triggers are executed after rules. However, when table or row buffering is in effect, triggers are not executed until the record (or records) are updated. (A record update occurs when the TABLEUPDATE( ) function is called or when the record pointer is moved while row buffering is in effect.)

Buffering and referential integrity can be used independently of each other, and the use of referential integrity does not require that buffering be used. In a multi-user environment, you would typically use buffering whether or not referential integrity is in use."



Can I customize the colors used to mark syntax in a VFP 5.0 edit window?

You can easily customize how your code looks by choosing Options from the Tools menu and selecting the Syntax Coloring tab in the Option dialog box. There you will find a variety of ways to customize the coloring of your code.

If you would like to turn syntax coloring off completely, from the Edit menu choose Properties to display the Edit Properties dialog box. Then clear the Syntax Coloring check box.



I receive an "Unhandled Exception" error when I connect to an Oracle server through ODBC.

When Visual FoxPro tries to connect, it uses a larger packet size (4K) than the normal ODBC default of 512 bytes. You can work around this problem by creating persistent connections, and by setting the PacketSize parameter to 512 bytes for the connections with the DBSetProp( ) function as shown below:

=DBSETPROP('myconnect', 'connect', 'packetsize', 512)

The default PacketSize for the current session can also be set to 512 bytes by using the following code:

=SQLSETPROP(0, 'packetsize', 512)

Note also that Oracle SQL*Net client version 7.1 is required. Contact Oracle to obtain this version.



I get errors in event and method procedures in forms and classes I've created. How do I debug them?

To view the program code in a method or event procedure for Forms and classes, place SET STEP ON at the beginning of the method or event procedure (or any other section of code you wish to step through one line at a time). Then use the Trace and Debug windows to debug your code.



How do I add blank rows to a grid?

The Grid control is designed to display records from a table, a view or a cursor. You add blank rows to a grid by issuing either APPEND BLANK or INSERT - SQL. By design, a grid cannot display elements from an array. If you do not want to create a file on disk for the information in a grid, consider using CREATE CURSOR to create a cursor (a temporary table in memory). After the cursor is created, use INSERT - SQL to add records to the cursor.



How can I count items within a report?

You can use a report variable to count items in a report.

Create a report variable by choosing Variables from the Report Menu.

Give the report variable a name, and add an IIF( ) function to the Variable to Store text box.

As the logical expression of the IIF( ) function, specify the condition for the records you want to count. As the first IIF( ) function return value, specify 1. As the second IIF( ) function return value, specify 0.

For example, the following IIF( ) function is used to count the number of records for the state of Washington (State = 'WA'). 1 is added to the report variable for each record. Records for other states are not counted because 0 is added to the report variable.

IIF(State = 'WA', 1, 0)

Choose the Sum button, and save the report variable.

Place a field in the group or page footer of the report, and specify the report variable for the report expression. When the report is previewed or printed, the field displays a total of all the records that match the condition specified in the IIF( ) function.



How do I use the Outline and MAPI controls?

Microsoft says: "The Outline control allows you to create a visual, hierarchical interface to files or other information. The Outline control interface is similar to the display of disks and files in the Windows file manager. The MAPI control is used to create a mail-enabled Visual FoxPro application. These controls are only available in the Professional Version of Visual FoxPro.

Both controls are available as OLE (.OCX) controls. The same procedure is used to add each one to your application as an OLE container. After the control is added, you invoke methods and set properties that are available within the OLE container object.

To add the control to your application visually, select the OLE container control from the Forms Control toolbar and drop it onto your form. The Insert Object dialog box is displayed. Choose the Insert Control option button, and choose the appropriate control type from the list box. Choose OK to return to your form.

To add an OLE control to your application programmatically, you must first add the control to your form with the AddObject method. Specify "OLECONTROL" as the second parameter in the AddObject method. Specify "MSOUTL.OUTLINE" as the third parameter for an Outline control. For a MAPI control, you must invoke the AddObject method twice. For the first object added to the form, specify "MSMAPI.MAPISESSION" as the third parameter. For the second object added to the form, specify "MSMAPI.MAPIMESSAGES" as the third parameter.

Use the Outline control's AddItem method to create the list of items that appear in the Outline control. To specify the indentation level for each item in the Outline control, use the Outline control's Indent property.

Visual FoxPro Help includes information for both of these controls. For more information about these controls, search Help for "Outline Control" or "MAPI Control."

For more information, see the following articles in the Microsoft Knowledge Base:

Article	Title
Q130728	OLE Controls Available in Visual FoxPro
Q135755	How to Use the OLE MAPI Control to Send Mail Messages
Q136638	How to Send Email Messages by using MS MAPI OLE Control
Q128073	PRB ADDITEM Does Not Add Item to an Outline Control
Q136270	How to Expand or Collapse an Outline Control Programmatically
Q136578	Code Samples Demonstrate How to Use the Outline Control"


Why is my SCAN awfully slow with large tables?
If you are using SCAN and have the alias part of a grid relation in your form, you should remove that tag prior to the SCAN. On large tables, 100000+ records, this will bring down the system from a flash to a few minutes.

LOCAL lcOrder
lcOrder=ORDER()
SCAN
   ...
ENDSCAN

SET ORDER TO (lcOrder)


Should I use my email features in all my applications?

No, you should use only one application being responsable of sending emails and/or receiving emails.

Each application should only be responsable to create the email records in the emails table which will be intepreted by the robot application.

In that way, you will optimize the waiting time in each of your application when come time to send emails by returning the control back to the user immediately after he confirms the send because your application will only create the record in the emails table and not send it.

Sometimes, the email server might be down or it might take time to get the connection with your ISP email server for example. Those situations will then be transparent to the user because the sending of all those emails will be done by the robot application instead.



Vitus@Vitus.com