We help IT Professionals succeed at work.


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.

I'm storing 32 byte strings in different places with different formats
Varbinary, Char(Binary) and Char. This is not optional. I'm dealing with legacy data.

I need to be able to concatanate them into a simple Char type string.

Trouble is, they need to be in that order (Varbinary, Char(Binary), Char) and, in VFP,  if you concatenate in that order, the result is Varbinary

How do I get to plain Char?
In answer to a previous question Arana provided the solution to my MySQL Search Syntax question with the following line:


which works a treat.

I am now trying to update an existing row using a similar line


but it doesn't work (instead I am prompted for the value of TARGHASH). Presumably this is because either the SELECT or WHERE command can accept the parameter but either the UPDATE or SET command cannot.

So how should I construct the command?
I have a Visual FoxPro application installed on windows server 2016. The ComboBoxes are not respecting the mouse position, or mouse clicks. So normally you would be able to move your cursor through the options and whichever option you are on would highlight blue as you move across them. Then you would be able to click on one of the choices and that option would be selected. Now; the application keeps the first option highlighted, and clicking on an option does not choose your selection but instead the highlighted one at the top.ComboBox in the application
I had this question after viewing To Reindex DBF file Using VB6.
I think that the answer to above question is only demonstrate that Microsoft DAO 3.51 Object Library can index database file. However, if an index file is corrupted/damaged, the DAO won't work properly. Normally, I need to fix the damaged index file via "reindex" command using Foxpro. So, I would like to know if there is a way to do the reindex in VB6.

Best Regards
Getting on pretty well with VFP uploading stuff into Mysql.

Got a problem coming the other way. Specifically, when I download the records from Mysql, all the fields defined as VARBINARY are landing in the VFP cursor as Memos instead of the VARCHAR(BINARY) I need.

I can write code that will convert them or suck the fields into a table with the right field types but given that this is an operation that may need to be performed millions of times a day, that's a bit of latency I would rather avoid. Is there a way to ensure that the downloaded data adopts the data type I require?
I've just installed MySQL on my desktop and am trying to connect to it from VFP.

I've prepped a User DSN call CodelODBC,
Server localhost
Port: 3306
User: Michael
Password: password
Database: none

I Click the Test button and get "Connection successful" which reassures me the DSN setup is valid

but, in VFP,  the line

STORE SQLSTRINGCONNECT('dsn=CodelODBC;uid=MICHAEL;pwd=password') TO gnhandle

always returns -1

I also tried
(after finding
https://efransiscus.wordpress.com/2009/03/15/tutorial-using-mysql-odbc-connector-with-foxpro-9-and-mysql/  )


but that falls over with "Command contains unrecognised Keyword..."

what am I missing?
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.
Hello.  Saving data to a SQL text column called dbo.Workorders.Description the first time through works, but the second time through the field is limited to 8000 characters.  

First I copy the data from the VFP view into a cursor and update some of the fields:

SELECT * FROM vWorkorderDetail WHERE .F. INTO CURSOR cWorkorderDetail READWRITE
REPLACE keyWorkorders WITH vWorkorders.keyWorkorders,;
            keyWorkorderDetail WITH lcTestID,;
            keyCategories WITH oApp.SQLConn.GetEmptyID(),;
            jobstatus WITH nJS,;        
            keyCreatedBy WITH oLib.GetEmployeesKey(oApp.Login),;
            keyModifiedBy WITH oLib.GetEmployeesKey(oApp.Login),;
            keyWorkorderDetailStatus WITH lcKeyStatus,;
            keyAssignedToEmp WITH oLib.GetEmptyID(),;
            keyAssignedToGroup WITH oLib.GetEmptyID(),;
            dtDueBy WITH {^1900/01/01 12:00:01 AM}

cWorkorderDetails.Description is the ControlSource of an EditBox.
Once the user is done updating the data on the form I save the data to the VFP view as such:

SELECT cWorkorderDetail

THERE ARE MULTIPLE m. = value lines, BUT NOT FOR m.Description.  cWorkorderDetail.Description IS THE CONTROLSOURCE FOR AN EDITBOX.

SELECT vWorkorderDetail
IF thisForm.isedit
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.
While I'll be delighted if anyone comes forward with a solution to this problem, I'm not expecting it. I'll settle for better ways, than I've so far tried, to diagnose it.

It is a perennial problem I've failed to resolve for about 15 years.  The symptom is simple to describe. In certain circumstances, the menu bar created with foxpro's menu.mpr or derivatives will suddenly start to flicker as though it's being refreshed or reloaded about 5-10 times a second.

I've never managed to figure out what causes this behaviour because it NEVER happens in the programming environment, only in the compiled exe.

I've tried writing loop traps and counters. I've tried writing simple logic traps which prevent any calls to run the menu code once it has been activated.

It has also, till now, been a low priority because it's occurrence has been rare, intermittent and unpredictable. On some installations it happens more than others (say, daily) and on some never. These differences persist even on identical workstations with identical sofware installed and running on the same network.

It's just become a priority because a new form I've added to the mix is causing the problem in an entirely predictable and routine manner - i.e. every time the modal form is invoked, on release back to the main form, we get the flicker. The flickering, incidentally, doesn't prevent the sofware working although it does become sluggish. Some users simply ignore it. Others are disturbed by it.

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!!!


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