|
5#
楼主 |
发表于 2008-1-28 10:32:43
|
只看该作者
Private Sub cmd_generate_result_Click()
Dim dbs As Database
Dim rsn As Recordset, rsxn As Recordset, rsy As Recordset, rsxy As Recordset
Dim distr_rate_type As String
Dim kaohe_term As Date
Dim distr_rate_term As Date
Set dbs = OpenDatabase("e:\我的文档\inform system\考核管理信息系统.mdb")
Set rsn = dbs.OpenRecordset("select * from 待匹配数据未匹配数据最终结果表")
Set rsxn = dbs.OpenRecordset("select * from 待匹配数据未匹配数据最终结果表期末用")
Set rsy = dbs.OpenRecordset("select * from 待匹配数据匹配数据最终结果表")
Set rsxy = dbs.OpenRecordset("select * from 待匹配数据匹配数据最终结果表期末用")
If IsNull(List63.ItemData(1)) Or IsNull(List73.ItemData(1)) Then
MsgBox "期初或期末的数据匹配类型或匹配次序没有设置,无法生成匹配数据表!", vbOKOnly, "系统提示"
Combo107.SetFocus
Exit Sub
End If
distr_rate_term = Combo107.Column(1)
kaohe_term = Combo67.Column(1)
'判断表中是否有记录,如果有记录,将被删除
If rsn.RecordCount > 0 Then
dbs.Execute "delete * from 待匹配数据未匹配数据最终结果表"
End If
If rsxn.RecordCount > 0 Then
dbs.Execute "delete * from 待匹配数据未匹配数据最终结果表期末用"
End If
If rsy.RecordCount > 0 Then
dbs.Execute "delete * from 待匹配数据匹配数据最终结果表"
End If
If rsxy.RecordCount > 0 Then
dbs.Execute "delete * from 待匹配数据匹配数据最终结果表期末用"
End If
'将期初数据导入到待分配表中,以便数据的分配
dbs.Execute "insert into 待匹配数据未匹配数据最终结果表 ( contract_number, sale_department, nation, operation, mainproduct_sort, revenue_first, cost_first, kaohe_term, contract_number_equipment, remark ) " & _
"select contract_number,sale_department,nation,operation,product_sort,期初收入,期初成本,kaohe_term,contract_number_equipment,remark from 待匹配数据整理表按合同号加总 where [kaohe_term]= [distr_rate_term] "
'将期末数据导入到待分配表中,以便数据的分配
dbs.Execute "insert into 待匹配数据未匹配数据最终结果表期末用 ( contract_number, sale_department, nation, operation, mainproduct_sort, revenue_final, cost_final, kaohe_term, contract_number_equipment,remark ) " & _
"select contract_number,sale_department,nation,operation,product_sort,期末收入,期末成本,kaohe_term,contract_number_equipment,remark from 待匹配数据整理表按合同号加总 where [kaohe_term]=[#kaohe_term#] "
MsgBox "报表数据成功生成!", vbOKOnly, "系统提示"
dbs.Close
End Sub |
|