|
Dim id, date2 As String
Me.单据类别 = 2
Me.单据日期.Value = Date
date2 = "S" & Right(Format([单据日期], "YYMMDD"), 5)
id = DMax("[单据编号]", "[销售出库]", "[单据编号] Like '" & date2 & "??'")
If IsNull(id) Then
Me.单据编号 = date2 & "01"
Me.单据编号.SetFocus
Else
Me.单据编号 = date2 & Format(CStr(CInt(Right(id, 2)) + 1), "00")
Me.单据编号.SetFocus
End If
Dim bian, ku, wan, wei, qi, qian, zi, shu, shao
Dim e As Currency
Dim ri As Date
Dim db As DAO.Database
Dim xiaoshuo, kuchunbiao, xiaori As DAO.Recordset
Dim strXs, strXs1, strXs2 As String
Set db = CurrentDb()
[B]strXs = "select 销售出库明细.商品编号,销售出库明细.商品类别,销售出库明细.品名规格,销售出库明细.进货价,销售出库明细.商品售价,销售出库明细.数量 from 销售出库明细 where 销售出库明细.销售出库ID = '" & Forms!报价窗口!销售出库ID & "'"[/B]运行到这里时就出现主题里所说的问题了。Set xiaoshuo = db.OpenRecordset(strXs, dbOpenDynaset)
Do While Not Rs.EOF
bian = xiaoshuo("商品编号")
shu = xiaoshuo("数量")
shao = xiaoshuo("商品售价")
strXs1 = "select 库存表.商品编号,库存表.商品进价 where 库存表.商品编号 = '" & bian & "'" & "and 库存表.完结 = " & False & ""
Set kuchunbiao = db.OpenRecordset(strXs1, dbOpenDynaset)
xiaoshuo("进货价") = kuchunbiao("商品进价")
kuchunbiao("库存量") = kuchunbiao("库存量") - shu
If kuchunbiao("库存量") = 0 Then
kuchunbiao("完结") = True
End If
kuchunbiao.Update
Set xiaori = db.OpenRecordset("销售日志", dbOpenDynaset)
xiaori.AddNew
xiaori("类型") = Me.单据类别.Column(1)
xiaori("日期") = Forms![报价窗口]![单据日期]
xiaori("商品编号") = bian
xiaori("数量") = shu
xiaori("商品进价") = xiaoshuo("进货价")
xiaori("商品售价") = shao
xiaori.Update
xiaoshuo.MoveNext
Loop
MsgBox "该报价单已转为销售单,请记住单据编号!", 64, "转换成功……"
End Sub
|
|