Visual FoxPro (VFP), and its predecessor FoxPro, is a data-centric, object-oriented, procedural, database programming language and IDE from Microsoft last released in 2007 that still has some active use due to its low cost of deployment and fairly rapid development. In 2008, Microsoft released a set of add-ons for VFP's xBase components to allow interoperability with various Microsoft technologies. It allows data processing against its native file-based data tables or database servers such as SQL Server.

Share tech news, updates, or what's on your mind.

Sign up to Post

Say you have an inventory with lots of possible part numbers for one physical item, such as for hardware.

Say you stored up to 10 part numbers in 10 fields in one record corresponding to the physical part.  These 10 part numbers could be thought of as distributors part numbers that refer to a manufacture part number.

How can you search on any one of those part numbers (don't assume its in any particular field)  and have it pull up the record in a quick way?
To amplify, it would be like if you searched the file on any possible distributor part number in order to pull up the manufacturer  indexed record, without know which distributor the part number came from.
I appear to have a deep misunderstanding of how VFP cursors work

My code is littered with examples like this as the quickest way to establish the presence of a record meeting arbitrary conditions where a simple INDEXSEEK isn't appropriate


This has worked for years.
Suddenly it doesn't.

I was so shocked, I assumed that either my data or my VFP installation had become corrupt.

I eliminated the former by trying it on various different tables from different sources

I eliminated the latter by first, thoroughly uninstalling all traces of VFP, then reinstalling it.

Then repeating the experiment on two other workstations where I had VFP installed.

The result is consistent.

What actually happens is that the Cursor is created with a filter matching (ANYCONDITION) and, if you're running this from a command line, for a few seconds you see the result you expect (eg 0 Records if you know that no records match the condition)  but then the status bar displays the name of the Cursor, its table of origin and the result count followed by RECCOUNT() of the original table (and now Cursor) (eg "Junk (path to table) Record 1/(RECCOUNT('ANYTABLE')") . The cursor is displaying the result count because it is now in a filter which matches ANYCONDITION.  But if I clear the filter (SET FILTER TO) what I have is a full copy of (ANYTABLE) …
Use A   && many records long

DO WHILE not eof()

      COPY NEXT 1 to bbb  && yes, it just keeps creating this one record file over and over


fails in when BBB is located on a network drive for some networks and works if BBB is located on the C drive. Why would that be? Could it be SMB1, 2 related?
I am using foxypreviewer to automate unattended invoice emailing.  The attended mode works fine but I have not been able to identify the location of the settings so that I can enter them automatically.  The foxypreviewer settings dbf identifies the names but setting those values including scattering them to mem does nothing to the process?
what is the location that foxypreviewer reads the email settings from?
Any idea why I am suddenly getting these errors when building executables?  I have SetStrictDate to 2 Constants Plus CTOD() AND CTOT().  These are two of the many errors I am getting.  CTOD AND CTOT is used throughout the applications.

Compiling s:\centerpoint\is\source\deshipman.scx
ldDateRun = CTOD(ldDateRun)
Error in line 13 of frmdeShipMan.cmndEmail.Click (record 13): CTOD and CTOT can produce incorrect results. Use DATE(y,m,d) or DATETIME(y,m,d,h,mm,s) instead, or recompile with STRICTDATE less than 2.

Compiling s:\centerpoint\is\classes\wscalendar.vcx
Error in line 7 of ws_calendar.oleCalendar.AfterUpdate (record 3): CTOD and CTOT can produce incorrect results. Use DATE(y,m,d) or DATETIME(y,m,d,h,mm,s) instead, or recompile with STRICTDATE less than 2.
Hi Experts

Could you clear from where the VFP date()  function obtains the current date?

Accordingly with:
The date used at printer is different from the Windows date (correct).

The user said me the BIOS date is incorrect, does the date used by the printer comes from BIOS?

Thanks in advance.
I need to export data from a VFP9 table to an .xls file.
One field in the xls file will be receiving two address lines, and needs the ALT Enter Code to create a CR/LF.
Can I put that code in the export file--
select  Line1 + ?? + Line 2 as address1

Alternatively can I export something like "xy" to mark the break and then search and replace in the xlsx?. Seems simple but when I use CTRL J or ALT 0010 as the replace character, I end up with a blank line between Line 1 and Line 2.
I have an application that is being tested by a co-worker.  Twice he has received "record out of range" error.  I have never gotten the error.

I have done extensive testing and modifications on my local machine with no error.  

We are also both testing the Foxpro app  remotely from our computers, connected to a server where the app will reside and run.

Here is a screen shot of the error from my coworker:

I suspect it is an issue with the remindlabes_um(dbf) CDX file.

I am copying the dbf and cdx files directly from the live environment to my test environment along with a number of other large dynamic "work tables" that are updated weekly.  Do I need to reindex them each time I copy them to Test? ... Is reindexing something that needs to be done routinely?
I have a table that looks like this:

For any record that has one of the descrip fields empty, I need to fill it with the value of the descrip field in the next column to the right and move the others over, if any.

If only the first field, decriptn is populated, the record gets deleted.

The result will look like this:

What's the best way to do this?
Connecting VFP Database File to Excel (pivot table).

I have a table in Visual Foxpro 9 that is being updated daily.
I would like to create a pivot table in Excel based on this table.

These are the steps I am following - but it is not working.. Please help.

1-Go to ODBC connection. Create a new one. Based on "Microsoft Dbase-Driver (*.dbf) _- Setup the name (DataCon) - Select version DBase IV - Select the directory where the Table is
2-go to excel - create a new document- Click on insert Pivot Table - Click on Choose connection -Browse for More-New source-ODBC DSN -Next - Select DataCon-Next- Select the table - raw-Name the connection (test.odc)-Finish
It gives me "ODBC DBase Driver - External Table is not in the expected format !
In my Visual Foxpro 9 program, I use Office Automation to process a third party Excel 97 file. All has been well for years. Now my client is dumping Office for Google Sheets. The third party file is still coming in that I need to process without Office. I found an interesting code to take XLSX without automation, but does not handle Excel 97 XLS. I asked my client to check with the third party to see if they can export as a XLSX, but in the meantime I am attempting to see if I can handle the Excel 97 without automation. I have attempted to use ODBC, from a similar question on foxite, but I don't seem to have the right code. I am hoping this has already been solved, I just haven't found it yet. Thanks in advance for your help.
How to allow multiple VFP app users to transparently transfer files to a secured shared directory.

I have multiple users connecting to a RDS server hosted on my domain.  There is a VPN between my domain and the users domain.  Once connected to the RDS server, they run their VFP app.  From within the VFP app, they select a file using GetFile().  That works fine.  Once a file is selected I want to automatically transfer the file to a shared directory, locked down to admins only.  Users wont have any access to the share except to upload files to it from within the VFP app.  

Here's a mockup of the credentials provided to me to access the share:
Domain: TheUsersDomains
Username: filestorageuser (given admin rights)
Password: FileStorePassw0rd
Location: \\TheirServer\FileStorage

At first, I replaced TheirServer with their servers IP, but VFP doesn’t seem to like IPs in a path, so I added a record to my workstations and to the RDS servers Hosts files.  Then, on my workstation, I connected to the server in File Explorer, entering in the credentials, and now VFP will upload files to it from my workstation.  However, when I create an executable and send it to the RDS server and try to upload files to the shared directory, I am given an error about …invalid path…

I have found some suggestions of a work around like this (I don't want to create a mapped drive the users can access outside of VFP):
oNet = CreateObject('WScript.Network')    
Hi Experts

Could you clear if a TRY CATCH / Finally could run independently of an habilitated ON ERROR clause by using VFP?

Actually I'm using a customized ON ERROR clause that deviates the error and its details to a txt file preventing the system to present an error popup.

I need to check a specific part of the code about network fails or some other obscure problem that rarely ocurs and I'm planning to use a TRY/ CATCH only on this code - without inabilitate the previous ON ERROR.

Thanks in advance.
I need to open a browse window.  Then open a second browse window when the user closes the first one.
      Tbe user needs to be able to activate the Data Session window from each browse window.  
      If I use browse ... nowait, the Data Session Window can be accessed by selecting Window from the menu and choosing Data Session.
      If I leave off nowait and select Window from the menu, The Command Window and Data Session Windows are grayed out.
      If I use nowait on both browse commands, the second browse window is not displayed.

	USE IN SELECT('ckRemindEdit')  
    use ckRemindEdit.dbf in 0
    select ckRemindEdit
	brow fields descrip 
	use in select('ckBreedEdit')
    use ckBreedEdit.dbf in 0
	brow fields descrip nowait[code]

Open in new window

The replace BREED commands on line 80 has been working for months and has suddenly stopped.

Replace Descrip-- fields starting on line 88 still work.

*!*	*-----------------------------------------
* -    cbBreedRemind_Update.prg
*!*	writes breed and label edits back to practices pull files
*!*	*-----------------------------------------

lparameter lcThisPath;
LOCAL laDirs[1];
set date to YMD
lcPrgNm = "ckBreedRemind_update.prg"
? lcPrgNm + " STARTED", datetime()

if empty(lcThisPath)
	lcThisPath = "c:\vetdata\_de\vetdata\"	

local lcWeekPullFile, ;
	lcWeekPullFileNam ;
	lcPath ;

set safety off 
set deleted on

if empty(lnWeekNum)
	lnWeekNum = 36

lcWeekNum = "9" + alltrim(right(str(100 + lnWeekNum),2))

lcWeekPullFile = "wk" + lcWeekNum + "_pull.dbf"

use in select('ScrubFile')
lcScrubFile = (lcThisPath) + "ckBreedScrub.dbf"
use (lcScrubFile) alias ScrubFile in 0 excl

select ScrubFile

*-- Create a liast of practice dirs	

SELECT scrubFile

*-- Close possibly open Pullfile

*-- Process all dirs
FOR lnI = 1 TO ALEN(laDirs)

  lcPullFile = lcThisPath + ALLTRIM(laDirs[m.lnI]) + "\pull\" + (lcWeekPullFile)
  IF FILE(m.lcPullFile)
    SELECT 0
    *-- Open Pullfile
    USE (m.lcPullFile) ALIAS PullFile
    *-- Update rows 

Open in new window

created a simple check for the existence of a field in a remote table. It failed, despite the existence of the relevant field. To troubleshoot why, I created the following very simple code which should enable you to recreate the issue. Bear in mind that you must NOT be in the remote table. (the whole point was to avoid leaving the table I was in and disturbing the existing pointers)

Create a table called phones, with a field called PHPRIME
create or use any other table and make it current

This is the code which demonstrates the problem:

FNAME=FIELD('PHPRIME','PHONES')  && that syntax clearly suggests we SHOULD be able to run the test more directly as in IF NOT FIELD('PHPRIME','PHONES')=='PHRIME'

*but it fails so I tried:

IF FNAME=='PHPRIME' && which it does

So, what hidden VFP secret am I missing here?
I need to connect some Visual FoxPro Tables with MS SQL server, a real time connection it's not necessary as long we are able to pull and return data to the Visual FoxPro Tables from MS SQL. I have downloaded from Microsoft and tested VFPOLEDB and VFPODBC drivers with no success.
Do someone has a ODBC driver or a way to connect those two type of data, that works?
Thanking in advanced!!!
I am opening a browse window, running some processes, then calling another program that opens a 2nd browse window.

I need them both to stay open until the user closes them.

If I just open one, it stays open.  If I open 2, they both flash on the screen then are closed.

select table1
go top
browse fields field1, field2, field 3 nowait

Call Program2
*-Program 2
select table2
go top
browse fields field1, field2, field 3 nowait
I am getting Alias filemaster not found on line 31.  I have tried various things as far as workspaces with no luck.

lcThisPath = "c:\inv\act\"      
close datab all
set safety off      
***For file1 lookup *****************************************************
use (lcThisPath) + "\filelist.dbf" in 0 shared
use (lcThisPath) + "\filemaster2.dbf" in 0 exclu
use (lcThisPath) + "\filemaster2.dbf" in 0 AGAIN ALIAS filemaster2_a SHARED

      brow last for len(alltrim(file1))>3 nowait

      select filemaster2
      set order to tag ufiled

            brow last nowait

      USE (lcThisPath) +  "templates\" + "ckfileEdit.dbf"
      select ckfileEdit

      COPY STRUCTURE TO (lcThisPath) + "\ckfileEdit.dbf"
      *-- close template file
      use in ckfileEdit

    use (lcThisPath) + "\ckfileEdit.dbf"


    select filemaster2
      set order to tag ufile3

    select ckfileEdit
    set relation to upper(substr(file,1,3)) into filemaster2 additive
      set relation to upper(substr(file,1,3)) into filelist_a additive
            select speciesd, species, filed, file, count(*) as cnt from (lcThisPath) + "ckfileScrub.dbf" group by species, speciesd, file, filed order by species, speciesd, file, filed into table ztemp.dbf      

      Select ckfileEdit
      Append from ztemp
      index on upper(filed) tag ufiled
      index on upper(substr(filed,1,3)) tag ufile3
      index on upper(substr(file,1,3)) tag ubr3
      set order to
      browse last fields cnt:R, species:20:R, speciesd:20:R, …
Hi Experts!

Could you point how to correctly call a VFP generical program from command line?

Accordingly with this project:

Local lcLogfile
lcLogfile = "d:\temp\task.log"
If ADir(paFiles, lcLogfile)=0
StrToFile(Textmerge("<<Sys(16,0)>> 001 -- 002  ran at <<Datetime()>> as <<Id()>>")+Chr(13)+Chr(10),lcLogfile,1)

Open in new window

That remains at
Called as:
Could you check how to do it correctly?

Thanks in advance!
Hi Experts

Could you point a way to show the combobox selected options when it's disabled when using Visual FoxPro?

When enabled: - The same  appearance is needed when disabled
Thanks in advance.
Hi Experts

Could you point a way to schedule JOBS by using Visual FoxPro, resembling in some manner MSSQLServer Agents Jobs ?

Even using VFP in conjunction with another tools.

Thanks in advance.
How do I tell if a record returned from a seek command is marked for deletion?

set safety off

SELECT scrubFile

    USE PullFile EXCL
      *-Search the Scrubfile based on Pullfile.PRRecno = Scrubfile.PRrecno
      IF SEEK(PRRecno, 'scrubFile')

               >> I need to add a condition here:
                       && if the scrubfile row found is not marked for deletion
                                   && Process the Pullfile record
                  && else
                         && delete the pull file record
                  && endif
    *- Pack both tables
I need help from someone familiar with VFP "Coverage"

Concerned with how long some of my forms take to load, I've rigged it such that, in development mode, on loading any form, it will ask if I want to set coverage on and, if so, it sets coverage to (formname).csv.

To review the results I suck the csv data into a COVERAGE.DBF table ordered by METHOD and run a report which itemises every method called, how long each one runs, how many times they're called and the total time spent running any given method.

All of which works like a charm and has helped me to refactor and streamline my software.

Today I hit a problem which I don't understand.

The form I'm trying to analyse is reported as having 49 calls to its LOAD method.

This made no sense, so I inserted a global counter as first line in the method. It reported, as I expected, just one call to the method.

What am I missing?
Hi Experts

Could you point a way you know  to allow a multiselect combobox (or optionally ListBox) by using Visual FoxPro?

Thanks in advance


Visual FoxPro (VFP), and its predecessor FoxPro, is a data-centric, object-oriented, procedural, database programming language and IDE from Microsoft last released in 2007 that still has some active use due to its low cost of deployment and fairly rapid development. In 2008, Microsoft released a set of add-ons for VFP's xBase components to allow interoperability with various Microsoft technologies. It allows data processing against its native file-based data tables or database servers such as SQL Server.

Top Experts In