|
本帖最后由 todaynew 于 2009-5-27 21:14 编辑
能不用窗体显示吗,最好直接拆分表中的数据到新表,因为并不需要点击后一个一个单号的拆!
rainless_9 发表于 2009-5-26 22:22
窗体还是只需要的,原因在于总需要在窗体上触发某个事件来完成拆分的工作。倒是可以一次将所有数据拆分完毕,方法是套一个移动主窗体记录的循环即可,方法如下:
Private Sub 拆分_Click()
.....
.....
Q = 999999.99
sql2 = "DELETE * FROM 临时表"
CurrentDb.Execute sql2
DoCmd.GoToRecord acDataForm, "主窗体", acFirst
Do While Me.单号.Value <> ""
sql1 = "select * from 订单明细 where 单号='" & Me.单号.Value & "'"
rs.Open sql1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 1 To rs.RecordCount
......
......
Next
rs.Close
DoCmd.GoToRecord acDataForm, "主窗体", acNext
Loop
Me.Form.Requery
End Sub |
|