If Not rs.EOF Then '第一次生成此明细回单 Do While Not rs.EOF '取信息 tt_cihdno = CStr(Format(Date, "yyyymmdd")) + Text1.Text tt_cipybm = Trim(rs.Fields("CIPYBM")) tt_cipyac = Trim(rs.Fields("CIPYAC"))
sql = "select sum(CIZFAM) as zfam1 from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIZFAM>0 and CIFSNO=''" Set rs3 = db.Execute(sql) tt_cihdtl = CStr(rs3.Fields("zfam1")) 'tt_cihdtl = CStr(db.Execute(sql))
sql = "select sum(CIZFAM) as zfam2 from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIZFAM<0 and CIFSNO=''" Set rs3 = db.Execute(sql) If IsNull(rs3.Fields("zfam2")) = True Then tt_citptl = "0.00" Else tt_citptl = CStr(rs3.Fields("zfam2")) End If 'tt_citptl = CStr(db.Execute(sql))
sql = "select count(*) as rotl from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIFSNO=''" Set rs3 = db.Execute(sql) tt_cirotl = CStr(rs3.Fields("rotl")) 'tt_cirotl = CStr(db.Execute(sql))
rs!Name = "xxxxxxx"
rs!Password = "ssssss"
rs.Update'每次添加完成一条都要执行这个Updaters.AddNew
rs!Name = "xxxxxxx"
rs!Password = "ssssss"
rs.Update
请多多帮忙!
rs.AddNew
rs!Name = "xxxxxxx"
rs!Password = "ssssss"
rs.Update'每次添加完成一条都要执行这个Update
rs.LockType = adLockOptimistic我在addnew以后确实马上update了。因为我在别的form里面addnew没有问题。所以我也怀疑是代码的问题,可是找不到问题:(请问记录集可能会出现什么问题?
for i=0 to 2
rs.AddNew
rs!Name = "xxxxxxx"
rs!Password = "ssssss"
rs.Update'每次添加完成一条都要执行这个Update
next
rs2.CursorLocation = adUseClient
rs2.CursorType = adOpenKeyset
rs2.LockType = adLockOptimistic sql = "select * from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIFSNO=''"
Set rs = db.Execute(sql)
'往临时表写明细信息
Dim row As Integer
row = 1
'打开临时表
rs2.Open "CZBYSWPZMXtmp", db, , , adCmdTable
If Not rs.EOF Then '第一次生成此明细回单
Do While Not rs.EOF
'取信息
tt_cihdno = CStr(Format(Date, "yyyymmdd")) + Text1.Text
tt_cipybm = Trim(rs.Fields("CIPYBM"))
tt_cipyac = Trim(rs.Fields("CIPYAC"))
sql = "select sum(CIZFAM) as zfam1 from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIZFAM>0 and CIFSNO=''"
Set rs3 = db.Execute(sql)
tt_cihdtl = CStr(rs3.Fields("zfam1"))
'tt_cihdtl = CStr(db.Execute(sql))
sql = "select sum(CIZFAM) as zfam2 from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIZFAM<0 and CIFSNO=''"
Set rs3 = db.Execute(sql)
If IsNull(rs3.Fields("zfam2")) = True Then
tt_citptl = "0.00"
Else
tt_citptl = CStr(rs3.Fields("zfam2"))
End If
'tt_citptl = CStr(db.Execute(sql))
sql = "select count(*) as rotl from CZBYSWZFPZ where CITRDT='" + CStr(Format((Form3.DTPicker1.Value), "yyyymmdd")) + "' and CIFSNO=''"
Set rs3 = db.Execute(sql)
tt_cirotl = CStr(rs3.Fields("rotl"))
'tt_cirotl = CStr(db.Execute(sql))
tt_cirono = CStr(row)
tt_cidjlx = Left(cidjlx, 2)
tt_cipydt = Trim(rs.Fields("CITRDT"))
tt_cifhno = Trim(rs.Fields("CIPNNO"))
tt_cizfam = CStr(Trim(rs.Fields("CIZFAM")))
tt_ciy1no = Trim(rs.Fields("CIY1NO"))
tt_ciitid = Trim(rs.Fields("CIITID"))
tt_ciecfg = Trim(rs.Fields("CIECFG"))
tt_cirvac = Trim(rs.Fields("CIRVAC"))
If citpyy = "全部" Then
tt_citpyy = ""
Else
tt_citpyy = Left(citpyy, 2)
End If
tt_cipati = cipati
tt_ciinno = Trim(rs.Fields("CIINNO"))
tt_ciamfg = Trim(rs.Fields("CIAMFG"))
tt_ciamug = Trim(rs.Fields("CIAMUG"))
tt_ciywdy = Trim(rs.Fields("CIYWDY"))
tt_ciszgl = Trim(rs.Fields("CISZGL"))
tt_ciprid = Trim(rs.Fields("CIPRID"))
tt_cifsno = Trim(Text1.Text)
'写数据库
'清空临时表
db.Execute ("delete from CZBYSWPZMXtmp")
'写数据进临时表
'Set rs2 = db.Execute("select * from CZBYSWPZMXtmp")
'rs2.Open "CZBYSWPZMXtmp", db, , , adCmdTable
rs2.AddNew
rs2.Fields("CIHDNO").Value = tt_cihdno
rs2.Fields("CIPYBM").Value = tt_cipybm
rs2.Fields("CIPYAC").Value = tt_cipyac
If tt_cihdtl <> "0.00" Then
rs2.Fields("CIHDTL").Value = CDbl(tt_cihdtl)
End If
rs2.Fields("CITPTL").Value = CDbl(tt_citptl)
rs2.Fields("CIROTL").Value = CLng(tt_cirotl)
rs2.Fields("CIRONO").Value = CLng(tt_cirono)
rs2.Fields("CIDJLX").Value = tt_cidjlx
rs2.Fields("CIPYDT").Value = tt_cipydt
rs2.Fields("CIFHNO").Value = tt_cifhno
rs2.Fields("CIZFAM").Value = CDbl(tt_cizfam)
rs2.Fields("CIY1NO").Value = tt_ciy1no
rs2.Fields("CIITID").Value = tt_ciitid
rs2.Fields("CIECFG").Value = tt_ciecfg
rs2.Fields("CIRVAC").Value = tt_cirvac
rs2.Fields("CITPYY").Value = tt_citpyy
rs2.Fields("CIPATI").Value = tt_cipati
rs2.Fields("CIINNO").Value = tt_ciinno
rs2.Fields("CIAMFG").Value = tt_ciamfg
rs2.Fields("CIAMUG").Value = tt_ciamug
rs2.Fields("CIYWDY").Value = tt_ciywdy
rs2.Fields("CISZGL").Value = tt_ciszgl
rs2.Fields("CIYWLX").Value = tt_ciywlx
rs2.Fields("CIPRID").Value = tt_ciprid
rs2.Fields("CIFSNO").Value = tt_cifsno
rs2.Update
row = row + 1
rs.MoveNext
Loop