|
2#
楼主 |
发表于 2015-7-11 10:17:43
|
只看该作者
本帖最后由 doney88 于 2015-7-11 10:19 编辑
一下是我现在窗体中所有的代码!
Private Sub cboBillType_AfterUpdate()
Dim strBillType As String
Dim strBillNum As String
Dim strBillNumIni As String '单据首字母
'自动生成单号
If Nz(Me.cboBillType) = "" Then Exit Sub
strBillType = Me.cboBillType
If strBillType = "出库" Then '单据首字母
strBillNumIni = "OT"
Else
strBillNumIni = "IN"
End If
strBillNum = Nz(DMax("Mid(FBillNum,3)", "tblPdtIvtData", "FBillType Like '" & Me.cboBillType & "'"), 0)
strBillNum = strBillNumIni & Format(strBillNum + 1, "000000")
Me.txtBillNum = strBillNum
'自动导入日期
Me.txtDate = DATE
End Sub
‘=====================================================================================================================
Private Sub cbo物料编号_AfterUpdate()
Dim intListIndex As Integer
Dim strPdtCode As String
Dim strColCode As String
intListIndex = Me.cbo物料编号.ListIndex
With Me.cbo物料编号
strPdtCode = Nz(.Column(1, intListIndex))
strColCode = Nz(.Column(2, intListIndex))
Me.txtProductCode = strPdtCode
Me.txtColorCode = strColCode
Me.txtColor = .Column(3, intListIndex)
Me.txtPrice = .Column(4, intListIndex)
End With
' '添加图片
' gf_GetPicPath Me.Pic, strPdtCode, strColCode
End Sub
’================================================================================================================================
Private Sub cbo物料编号_Change()
'
Dim strCriteria As String
strCriteria = Me.cbo物料编号.Text
Me.cbo物料编号.RowSource = "SELECT 表_采购_物料数据.物料编号, tblProduct.FProductCode, tblProduct_SKU.FColorCode, tblProduct_SKU.FColor, 表_采购_物料数据.单价" & _
" FROM 表_采购_物料数据 INNER JOIN (tblProduct INNER JOIN tblProduct_SKU ON tblProduct.FProductID = tblProduct_SKU.FProductID) ON 表_采购_物料数据.FMaterialID = tblProduct_SKU.FMaterialID" & _
" Where FProductCode Like '*" & strCriteria & "*' Or 物料编号 Like '" & strCriteria & "'"
Me.cbo物料编号.Dropdown
End Sub
Private Sub cbo物料编号_KeyDown(KeyCode As Integer, Shift As Integer)
ArrowSelectList Me.cbo物料编号, KeyCode
End Sub
‘========================================================================================================================
Private Sub cmdInsert_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Set db = CurrentDb
Set rst = db.OpenRecordset("tblPdtIvtData_Temp")
rst.AddNew
rst!物料编号 = Me.cbo物料编号
rst!FQty = Me.txtQty
rst!FPrice = Me.txtPrice
rst!FNote = Me.txtNote
rst.Update
rst.Close: Set rst = Nothing
db.Close: Set db = Nothing
Me.Requery
End Sub
’==============================================================================================================
Private Sub cmdOpenBill_Click()
Me.txtBillNum = Null
Me.cboBillType = Null
Me.txtDate = Null
CurrentDb.Execute "Delete From tblPdtIvtData_Temp"
Me.Requery
End Sub
‘===============================================================================================================
Private Sub cmdSave_Click()
Dim strBillNum As String
Dim strBillType As String
Dim datePdtIvt As Date
Dim strSql As String
On Error GoTo HandleError
strBillNum = Me.txtBillNum
strBillType = Me.cboBillType
datePdtIvt = Me.txtDate
strSql = "Update tblPdtIvtData_Temp Set FBillNum='" & strBillNum & "',FBillType='" & strBillType & "'," & _
"FDate=#" & datePdtIvt & "#"
CurrentDb.Execute strSql
strSql = "Insert Into tblPdtIvtData(FBillNum,FBillType,FSKUID,物料编号,FQty,FPrice,FDate,FNote)" & _
" Select FBillNum,FBillType,FSKUID,物料编号,FQty,FPrice,FDate,FNote From tblPdtIvtData_Temp"
CurrentDb.Execute strSql
If IsLoaded("frmPdtIvt") Then Forms!frmPdtIvt.Requery
MsgBox "保存成功!", vbInformation
Exit_Sub:
Exit Sub
HandleError:
If Err.Number <> 0 Then
If Err = 94 Then
MsgBox "单号、单据类型、日期不能为空!", vbCritical
Else
MsgBox Err & vbCrLf & Err.Description
End If
End If
GoTo Exit_Sub
End Sub
’=====================================================================================================================
Private Sub Form_Current()
Dim strPdtCode As String
Dim strColCode As String
If Me.NewRecord Then Exit Sub
strPdtCode = Me.FProductCode
strColCode = Me.FColorCode
gf_GetPicPath Me.Pic, strPdtCode, strColCode
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|