The code below is designed to remove the previos year and store for retrieval when necessary. It has worked for years 1995 thru 2001, but only writes a file (500 bytes or so) now.
BTW, the adding of Y to the beginning of the year name seems to suit Alpha better than when the db name begins with a number.
a_tbl = table.open("dues.dbf")
new_name = "y"+alltrim(str(year(date()-365)))
query.order = "lastname+firs_nam+midinit"
query.filter = "substr(datepaid,9,2)=substr(new_name,3,2)"
a_tbl.query_create()
copy.set = ""
copy.db = "c:\program files\a5v4\union"+chr(92)+new_name+".dbf"
copy.dd = .t.
copy.delete_o_dd = .f.
copy.records = .t.
copy.fields = 10
copy.field1 = "lastname"
copy.field2 = "datepaid"
copy.field3 = "duespaid"
copy.field4 = "assesspaid"
copy.field5 = "percent"
copy.field6 = "trade"
copy.field7 = "dues"
copy.field8 = "firs_nam"
copy.field9 = "midinit" '20
copy.field10 = "dept_num"
a_tbl.copy()
file_add_to_db("c:\program files\a5v4\union"+chr(92)+new_name+".dbf")
query.order = "lastname+firs_nam+midinit"
a_tbl.close()
a_tbl.open("dues")
a_tbl.delete_range("substr(dtoc(date()-365),7,4)"=substr(duespaid,7,4)")
a_tbl.close()
a_tbl=table.open(alltrim(new_name)+".dbf")
a_tbl.index_create_begin("lstfstmid","lastname+firs_nam+midinit")
index1=a_tbl.index_create_end()
ui_msg_box("Index","Index has been created.")
'a_tbl.index_get("lstfstmid")
a_tbl.index_primary_put("lstfstmid")
a_tbl.close()
end
Is there a way to improve this or should a different approach be developed? Since this has been used 7 times satisfactorally I see no reason for it to quit now.
All help will be greatly appreciated,
efs
BTW, the adding of Y to the beginning of the year name seems to suit Alpha better than when the db name begins with a number.
a_tbl = table.open("dues.dbf")
new_name = "y"+alltrim(str(year(date()-365)))
query.order = "lastname+firs_nam+midinit"
query.filter = "substr(datepaid,9,2)=substr(new_name,3,2)"
a_tbl.query_create()
copy.set = ""
copy.db = "c:\program files\a5v4\union"+chr(92)+new_name+".dbf"
copy.dd = .t.
copy.delete_o_dd = .f.
copy.records = .t.
copy.fields = 10
copy.field1 = "lastname"
copy.field2 = "datepaid"
copy.field3 = "duespaid"
copy.field4 = "assesspaid"
copy.field5 = "percent"
copy.field6 = "trade"
copy.field7 = "dues"
copy.field8 = "firs_nam"
copy.field9 = "midinit" '20
copy.field10 = "dept_num"
a_tbl.copy()
file_add_to_db("c:\program files\a5v4\union"+chr(92)+new_name+".dbf")
query.order = "lastname+firs_nam+midinit"
a_tbl.close()
a_tbl.open("dues")
a_tbl.delete_range("substr(dtoc(date()-365),7,4)"=substr(duespaid,7,4)")
a_tbl.close()
a_tbl=table.open(alltrim(new_name)+".dbf")
a_tbl.index_create_begin("lstfstmid","lastname+firs_nam+midinit")
index1=a_tbl.index_create_end()
ui_msg_box("Index","Index has been created.")
'a_tbl.index_get("lstfstmid")
a_tbl.index_primary_put("lstfstmid")
a_tbl.close()
end
Is there a way to improve this or should a different approach be developed? Since this has been used 7 times satisfactorally I see no reason for it to quit now.
All help will be greatly appreciated,
efs
Comment