|
5#
楼主 |
发表于 2010-7-11 00:46:58
|
只看该作者
本帖最后由 hljthzbc 于 2010-7-11 00:53 编辑
版主好:我不会写代码:
可是liwen版主没有把代码写全呀,谁在再帮我把字段写全吧:还有几个字段没有写上.调用不出来.
Sub 生成新表()
Dim conn As New ADODB.Connection
Set conn = CurrentProject.Connection
Dim RST As New ADODB.Recordset
Dim SQL As String
' Dim cat As New ADOX.Catalog
' Dim cmd As New ADODB.Command
Dim rst1 As New ADODB.Recordset
' cat.ActiveConnection = conn
SQL = "DELETE 产销表W.* FROM 产销表W"
DoCmd.RunSQL SQL
sq = 0
sclj = 0
xslj = 0
qmkc = 0
RST.Open "交叉表", conn, adOpenKeyset, adLockOptimistic
rst1.Open "产销表W", conn, adOpenKeyset, adLockOptimistic
Do While Not RST.EOF
If cpid = RST("产品ID") Then
If ldid = RST("年度ID") Then
sclj = sclj + Nz(RST("生产"))
xslj = xslj + Nz(RST("销售"))
kc = qq + sclj - xslj
Else
qq = kc
sclj = Nz(RST("生产"))
xslj = Nz(RST("销售"))
End If
Else
'qq = RST("前期")
sclj = Nz(RST("生产"))
xslj = Nz(RST("销售"))
kc = qq + sclj - xslj
End If
rst1.AddNew
rst1("年度ID") = RST("年度ID")
rst1("月份ID") = RST("月份ID")
rst1("产品ID") = RST("产品ID")
rst1("生产") = RST("生产")
rst1("销售") = RST("销售")
rst1("前期") = qq
rst1("生产累计") = sclj
rst1("销售累计") = xslj
rst1("库存") = kc
rst1.Update
cpid = RST("产品ID")
ldid = RST("年度ID")
yfid = RST("月份ID")
RST.MoveNext
Loop
rst1.Update
End Sub
'先按相应的字段做一个“查询结果”表,其它字段请自己补齐
Private Sub Form_Load()
'Me.Requery
Me.产销表W子窗体.Form.Requery
End Sub
我想实现的就是在窗体本身可以自由的更新数据.目前只能把数据删除.可是生成还不行.
那位版主帮助实现这两个要求.在此首先谢谢liwen自主.一并也谢谢给予指点的各位大师了
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|