Let's say I'm working with a FoxPro table called Org, and among its many columns it has a column called 'comm_typ'. If I have Org currently selected, and I say:
SET FILTER TO comm_typ = 'A'
Pretty simple, right? And it works fine; no errors, and only records with a comm_typ value of 'A' get returned.
However, if I try using that same logical expression to pare down an APPEND FROM command, FoxPro doesn't like it. If I issue the following commands:
Use Org in 1
Use Temp in 2
Select Temp
APPEND FROM Org for comm_typ = 'A'
I get this error on the APPEND FROM: 'You must use a logical expression with a FOR or WHILE clause.'
I've double- and triple-checked the expected syntax on the APPEND FROM command, I've verified that there are actually records with comm_typ values of 'A' to be appended.
EDIT: I figured it out.
All the columns that give me an error when plugged into an APPEND FROM...FOR... command all have one thing in common: they contain NULL values. Not just an empty field, an actual .NULL. is what the APPEND FROM is choking on. On my Org table I issued this command:
REPLACE comm_typ WITH '' FOR ISNULL(comm_typ)
I then tried the append from again, and it worked. Another possible workaround, rather than replacing all nulls with blanks, is to adjust the FOR clause to account for the nulls, like this:
APPEND FROM Org FOR comm_typ = 'A' .and. !ISNULL(comm_typ)
These nulls exist because my office is in the midst of a transition from FoxPro to SQL Server, and in some cases we have data bouncing back and forth between FoxPro and SQL Server. When an empty FoxPro field is mapped to SQL Server, it gets represented as a NULL, and when that gets dumped back into a FoxPro remote view, it is represented as .NULL.