设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 101|回复: 0
打印 上一主题 下一主题

[窗体] 对于子窗体入库完成,主窗体订单状态锁定问题

[复制链接]
跳转到指定楼层
1#
发表于 2025-1-11 12:25:01 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
对于子窗体入库完成,主窗体订单状态锁定问题"
1子窗体的收货数量=订单数量,后行状态锁定,如果整个订单明细都完成入库,这个订单状态就锁定
请帮助看看下面代码如何增加,谢谢
Private Sub Qty_receive_AfterUpdate()
On Error GoTo Err_Qty_receive_AfterUpdate  '20131106  重新定义收货方法
'Qty_receive

    Dim x As Integer
    Dim y As Long
     Dim SQLText As String
      Dim Step As Integer
    If Me.Qty_receive = 0 Then Exit Sub

    x = Me.Received_TotalofQty + Me.Qty_receive

    If x > Me.Qty_Order Then         '收货数量>订单数量
        MsgBox "收货数量合计已超过本单订货数量。请重新输入。", vbCritical, "提示"
        Me.Qty_receive = 0
        x = 0
        Me.Qty_Order.SetFocus
        Me.Qty_receive.SetFocus
        Exit Sub
    End If
    If x = Me.Qty_Order Then     '收货数量=订单数量

    Step = 1
        SQLText = "UPDATE [tblProduct_Stock_Remote] SET [tblProduct_Stock_Remote].[Real_Qty] =Forms![frmPurchase_Order]![SubPo].Form![Qty_receive]+[tblProduct_Stock_Remote]![Real_Qty]WHERE ((([tblProduct_Stock_Remote].[ITEM])=Forms![frmPurchase_Order]![SubPo].Form![Parts No]));"
         DoCmd.RunSQL SQLText
    Step = 2
        SQLText = "INSERT INTO [tblStockIn/Out_Remote] ( [Item], [Date], In_Out, [ID Motive], Quantity)" 'NOTE
        SQLText = SQLText + "SELECT Forms![frmPurchase_Order]![SubPo].Form![Parts No] AS [Item], date() AS [Date], 'I' AS [IN_Out], '03' AS [ID Motive], Forms![frmPurchase_Order]![SubPo].Form![Qty_receive] AS [Quantity];" ',Forms![frmPurchase_Order]![SubPo].Form![TEXT20] AS [NOTE];"
         DoCmd.RunSQL SQLText
      '  SQLText = "INSERT INTO [tblStockIn/Out_Remote] ([note])"
       ' SQLText = SQLText + "SELECT Forms![frmPurchase_Order]![PO_No] AS [Quantity];"
         DoCmd.RunSQL SQLText
        Me.Received_TotalofQty = x
        Me.No_Receving_Qty = [Qty_Order] - [Received_TotalofQty]
        Me.Received_Date = Date

        Me.Qty_receive = 0
        Me.Received_TotalofQty.SetFocus
       ' Me.Qty_receive.Enabled = False
        Me.Receive_Status.Locked = True

    MsgBox "这个物料已完成收货"
    Else                              '收货数量<订单数量
        y = MsgBox("收货数量小于本单订货数量,是否确定属于分批收货?", vbYesNo + vbQuestion, "提示")
        If y = vbNo Then

            Me.Qty_Order.SetFocus
            Me.Qty_receive.SetFocus
            x = 0
            Exit Sub
        Else
        Step = 1
           SQLText = "UPDATE [tblProduct_Stock_Remote] SET [tblProduct_Stock_Remote].[Real_Qty] =Forms![frmPurchase_Order]![SubPo].Form![Qty_receive]+[tblProduct_Stock_Remote]![Real_Qty]WHERE ((([tblProduct_Stock_Remote].[ITEM])=Forms![frmPurchase_Order]![SubPo].Form![Parts No]));"
           DoCmd.RunSQL SQLText
        Step = 2
            SQLText = "INSERT INTO [tblStockIn/Out_Remote] ( [Item], [Date], In_Out, [ID Motive], Quantity)"   'NOTE
            SQLText = SQLText + "SELECT Forms![frmPurchase_Order]![SubPo].Form![Parts No] AS [Item], date() AS [Date], 'I' AS [IN_Out], '03' AS [ID Motive], Forms![frmPurchase_Order]![SubPo].Form![Qty_receive]  AS [Quantity];" ',Forms![frmPurchase_Order]![SubPo].Form![TEXT20] AS [NOTE];"
             DoCmd.RunSQL SQLText

        Me.Received_TotalofQty = x
        Me.No_Receving_Qty = [Qty_Order] - [Received_TotalofQty]
        Me.Received_Date = Date
            'Me.Qty_receive = 0
        End If
    End If
     Me.Qty_receive = 0
     Me.Requery

Exit_Qty_receive_AfterUpdate:
    Exit Sub

Err_Qty_receive_AfterUpdate:
    Resume Exit_Qty_receive_AfterUpdate

'xxxxxxxxxxxxxxxxxxxxxxxxxxxx
If Me.Qty_receive = "" Then
        Me!Received_Date = ""
        Else
        Me!Received_Date = Date
    End If
  If Me.Received_TotalofQty = Me.Qty_Order Then
    Me.Receive_Status.Locked = True
     Else
     Me.Receive_Status.Locked = False
End If


End Sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-1-23 17:42 , Processed in 0.112068 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表