I have a table of records based on Months of Year. So there is a field for Month and a field for Year plus other fields. The form is based on a set with Accounts being parent and Expenses the child (one to many) The form has two embedded browses: Accounts and Expenses. Expenses filtered on the global variable - glo_Year. I use xbasic to populate a years worth of data (12 records) for the selected Account. When I populate the data, I want to know if there is data for the prior year so I can get budget info from those 12 records prior to entering the new records.
This is what I'm playing around with and am getting the "Argument is incorrect data type" error on the "qryPrev" line.
I've used this technique in other scripts without errors, but it doesn't want to work in this situation. Not sure if this is a good way to query the same table in multiple ways or not. Any guidance greatly appreciated.
Ernie
This is what I'm playing around with and am getting the "Argument is incorrect data type" error on the "qryPrev" line.
Code:
tbl = table.open("expenses") tbl2 = table.open("accounts") query.filter = "Type_Acct = 'Expense'" query.order = "" query.Options = "" qry2 = tbl2.query_create() tbl2.fetch_first() while .not. tbl2.fetch_eof() vacctID = tbl2.Acct_id vYear = var->glo_Year query.filter = "acct_id = "+s_quote(vacctID)+" .and. plan_year = "+s_quote(vYear) query.order = "aplan_id" qry = tbl.query_create() qrecs = qry.records_get() if qrecs > 0 then tbl2.fetch_next() else qry.drop() '[COLOR="Red"]not sure if this is necessary[/COLOR] vacctID = tbl2.Acct_id vYear = (var->glo_Year - 1) '[COLOR="Red"]see if any prior year data[/COLOR] query.filter = "acct_id = "+s_quote(vacctID)+" .and. "+s_quote(vYear) query.order = "aplan_id" qryPrev = tbl.query_create() '[COLOR="Red"]<< ERROR >>[/COLOR] end if tbl2.fetch_next() end while
Ernie
Comment