Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

怎样把移除代码变成增加代码

无量佛  发表于:2011-12-14 14:28:30  
复制

这是一个反月结代码,怎样变成月结代码

Private Sub cmdOK_Click()
    Dim Dbs As Database
    Dim sFilter As String
    Dim sSql As String
   
    Dim i As Integer                '当前月份
    Dim j As Integer                '上个月份
    Dim sStock_Year, sStock_PreYear As String        '上个月年份和月份
    Dim dBeginningDate, dEndingDate As Date     '当前月份的开始日期和结束日期
    Dim sPassword As String
   
    Set Dbs = CurrentDb
   
'    sPassword = InputBox("请输入您的密码", "提示:", "")
'    If IsNull(sPassword) Or sPassword = "" Then
'        Exit Sub
'    Else
'        If IsNull(DLookup("Password", "Oprator", "Password='" + sPassword + "'")) Then
'            MsgBox "密码不对,请重新输入", vbInformation + vbOKOnly, "提示:"
'            Exit Sub
'        End If
'    End If
   
    sStock_Year = DLookup("CurrentYear", "Company", "")     '当前年份
    sStock_PreYear = Trim(Str(CDbl(sStock_Year) - 1))       '去前年份
    i = DLookup("CurrentMonth", "Company", "")              '当前月份
    j = i - 1                                               '上月月份
   
    dBeginningDate = dhFirstDayInMonth(sStock_Year + "-" + IIf(i > 9, Trim(Str(i)), "0" + Trim(Str(i))) + "-01")
    dEndingDate = dhLastDayInMonth(sStock_Year + "-" + IIf(i > 9, Trim(Str(i)), "0" + Trim(Str(i))) + "-01")
   
    '先清除本月明细帐数据
    sSql = " Delete From Material_MXZ where format(MXZ_Date,'yyyy-mm')='" + sStock_Year + "-" + IIf(i > 9, Trim(Str(i)), "0" + Trim(Str(i))) + "'"
    Dbs.Execute sSql
    '删除本月收发存总帐数据
    sSql = " Delete From Material_ZZ where format(ZZ_Date,'yyyy-mm')='" + sStock_Year + "-" + IIf(i > 9, Trim(Str(i)), "0" + Trim(Str(i))) + "'"
    Dbs.Execute sSql
   
    If j = 0 Then               '1月份
        '先清除上月明细帐数据
        sSql = " Delete From Material_MXZ where format(MXZ_Date,'yyyy-mm')='" + sStock_PreYear + "-12'"
        Dbs.Execute sSql
        '删除上月收发存总帐数据
        sSql = " Delete From Material_ZZ where format(ZZ_Date,'yyyy-mm')='" + sStock_PreYear + "-12'"
        Dbs.Execute sSql
    Else
        '先清除上月明细帐数据
        sSql = " Delete From Material_MXZ where format(MXZ_Date,'yyyy-mm')='" + sStock_Year + "-" + IIf(j > 9, Trim(Str(j)), "0" + Trim(Str(j))) + "'"
        Dbs.Execute sSql
        '删除上月收发存总帐数据
        sSql = " Delete From Material_ZZ where format(ZZ_Date,'yyyy-mm')='" + sStock_Year + "-" + IIf(j > 9, Trim(Str(j)), "0" + Trim(Str(j))) + "'"
        Dbs.Execute sSql
    End If
   
    '修改本月入库单POST标志
    sSql = "UPDATE Material_IN SET Material_In.Post = False"
    sSql = sSql & " WHERE Material_IN.IN_Date Between #" & Format(dBeginningDate, "yyyy-mm-dd") & "# And #" & Format(dEndingDate, "yyyy-mm-dd") & "#"
    Dbs.Execute sSql
   
    '修改本月出库单POST标志
    sSql = "UPDATE Material_out SET Material_out.Post = False"
    sSql = sSql & " WHERE Material_out.Out_Date Between #" & Format(dBeginningDate, "yyyy-mm-dd") & "# And #" & Format(dEndingDate, "yyyy-mm-dd") & "#"
    Dbs.Execute sSql
   
    If j = 0 Then
        dBeginningDate = dhFirstDayInMonth(sStock_PreYear + "-12" + "-01")
        dEndingDate = dhLastDayInMonth(sStock_PreYear + "-12" + "-01")
    Else
        dBeginningDate = dhFirstDayInMonth(sStock_Year + "-" + IIf(j > 9, Trim(Str(j)), "0" + Trim(Str(j))) + "-01")
        dEndingDate = dhLastDayInMonth(sStock_Year + "-" + IIf(j > 9, Trim(Str(j)), "0" + Trim(Str(j))) + "-01")
    End If
    '修改上月入库单POST标志
    sSql = "UPDATE Material_IN SET Material_In.Post = False"
    sSql = sSql & " WHERE Material_IN.IN_Date Between #" & Format(dBeginningDate, "yyyy-mm-dd") & "# And #" & Format(dEndingDate, "yyyy-mm-dd") & "#"
    Dbs.Execute sSql
   
    '修改上月出库单POST标志
    sSql = "UPDATE Material_out SET Material_out.Post = False"
    sSql = sSql & " WHERE Material_out.Out_Date Between #" & Format(dBeginningDate, "yyyy-mm-dd") & "# And #" & Format(dEndingDate, "yyyy-mm-dd") & "#"
    Dbs.Execute sSql
    
        
    MsgBox "反月结已完毕", vbInformation + vbOKOnly, "提示:"
End Sub

 

Top
总记录:0篇  页次:0/0 9 1 :