|
Dim bian, ku, wan, wei, qi, qian, zi
Dim e As Currency
Dim ri As Date
Dim db As DAO.Database
Dim rec, Rs1 As DAO.Recordset
Dim strXs As String
bian = " [商品编号] ='" & Forms![销售出库]![销售出库子窗体]![商品编号] & "'"
qian = " [商品进价] =" & Forms![销售出库]![销售出库子窗体]![进货价] & " "
wan = "[完结]=" & False
wei = Forms![销售出库]![销售出库子窗体]!数量
Set db = CurrentDb()
strXs = "select 库存表.日期,库存表.库存量,库存表.完结,库存表.商品进价 from 库存表 where 库存表.商品编号 = '" & Forms!销售出库!销售出库子窗体!商品编号 & "'" & "and 库存表.完结 = " & False & ""
Set rec = db.OpenRecordset(strXs, dbOpenDynaset)
If IsNull(rec("日期")) Then
MsgBox "库存中没有该商品信息,请确认是否已入库!", 16, "警告"
Exit Sub
End If
Do While wei > 0 Or Not rec.EOF
If rec("库存量") > wei Then
rec.Edit
rec("库存量") = rec("库存量") - wei
Forms![销售出库]![销售出库子窗体]![进货价] = rec("商品进价")
rec.Update
Set Rs1 = db.OpenRecordset("销售日志", dbOpenDynaset)
Rs1.AddNew
Rs1("日期") = Forms![销售出库]![单据日期]
Rs1("商品编号") = Forms![销售出库]![销售出库子窗体]![商品编号]
Rs1("数量") = wei
Rs1("商品进价") = rec("商品进价")
Rs1("商品售价") = Forms![销售出库]![销售出库子窗体]![商品售价]
Exit Do
Else
rec.Edit
wei = wei - rec("库存量")
Forms![销售出库]![销售出库子窗体]![进货价] = rec("商品进价")
rec("库存量") = 0
rec("完结") = True
rec.Update
Set Rs1 = db.OpenRecordset("销售日志", dbOpenDynaset)
Rs1.AddNew
Rs1("日期") = Forms![销售出库]![单据日期]
Rs1("商品编号") = Forms![销售出库]![销售出库子窗体]![商品编号]
Rs1("数量") = wei
Rs1("商品进价") = rec("商品进价")
Rs1("商品售价") = Forms![销售出库]![销售出库子窗体]![商品售价]
End If
rec.MoveNext
Loop
代码是这样吗?好像不行耶,我加了进去,没反应! |
|