Selecting a record that is updating
* and others You do not tell us where your code above 'falls apart'.
Does it throw an error message or just not give you the answer you want?
Things like: * where does maxid 'live' * where is curid initialized going into the DO/ENDDO loop?
* is the data table ai_enc already open before the DO/ENDDO loop?
A filter condition should filter some table field, shouldn't it?
If progam is a table field you still don't need extra delimiters just because it's a reserved word.
DO WHILE maxid = curid SELECT era_proj_actuals locate for id1 = curid curprog = prog_id curservcat = serv_catcur1yrstartdt = oneyrstartdtcur1yrenddt = oneyrenddtcurconno = conno IF curservcat in ('00015', '00016', '00017', '00018', '00019', '00043', '00044', '00047', '00048') thencuractenc = (select COUNT(act_id) from ai_enc where conno = curconno and serv_cat = curservcat and 'program' = curprog and act_dt It would be easier to understand, if you come over with the SQL foxpro can't execute.
One thing I spot is you trying to set a variable to an sql result. An SQL ends in a resultset, even select count() dfoes not result in a single scalar value. into cursor cur Resultcuractenc = cur Result.n Count Besides that you can't do IF var in (list of values)What you can do instead is IF inlist(var, list of values)Besides I don't see a rough error.
I'm able to do this in sql without any problems but very little translates over well from sql to foxpro.
IF INLIST(curservcat, "00015", "00016", "00017", "00018", "00019", "00043", "00044", "00047", "00048") = . The use of SET FILTER is not a best practice, particularly since you appear to be using it solely for the COUNT.