怎樣實現以下自動編號,
物料储位編號從000A,000B,000C.....199A,199B,199C;
以下SQL怎樣實現储位自動編號;Private Sub NewAdd_Click()
'2009.11.14
Dim sql3 As String
'判斷新增料號是否為空
If AddMaterial.Text = "" Then
MsgBox "新增料號1不能為空,請重新輸入新增料號!", 0, "提示!"
AddMaterial.SetFocus
Exit Sub
Else
'判斷料號長度是否符合規則
If Len(AddMaterial.Text) <> 8 And Len(AddMaterial.Text) <> 9 Then
MsgBox "輸入新增料號長度不符,請重新輸入新增料號!", 0, "提示!"
AddMaterial.Text = ""
AddMaterial.SetFocus
Exit Sub
Else
'判斷料號是否已經存在
sql3 = "select *from Material where MaterialSkuno='" & AddMaterial.Text & "'"
Set rs = TransactSQL(sql3)
If rs.EOF = False Then
MsgBox "輸入新增料號已經存在,請重新輸入新增料號!", 0, "提示"
AddMaterial.Text = ""
MaterialDescription1.Text = ""
StorageSpaces1.Text = ""
AddMaterial.SetFocus
Exit Sub
Else
'判斷物料描述是否為空
If MaterialDescription1.Text = "" Then
MsgBox "物料描述不能為空,請輸入物料描述!", 0, "提示!"
StorageSpaces1.Text = ""
MaterialDescription1.SetFocus
Exit Sub
Else
'判斷储位是否為空
If StorageSpaces1.Text = "" Then
MsgBox "储位不能為空,請輸入储位!", 0, "提示"
StorageSpaces1.SetFocus
Exit Sub
Else
'2009.11.15 新增
'判斷储位是否已經使用,如已經在使用,需重新分配储位 問題:怎樣實現储位自動編號
Dim sql6 As String
sql6 = "select *from Material where StorageSpaces='" & StorageSpaces1.Text & "'"
Set rs = TransactSQL(sql6)
If rs.EOF = False Then
MsgBox "該储位應經使用,請輸入另外的储位!", 0, "提示"
StorageSpaces1.Text = ""
StorageSpaces1.SetFocus
Exit Sub
Else
'插入料號到表"Material"
sql3 = "insert into Material(MaterialSkuno,MaterialDescription,StorageSpaces,GoodMaterial,FailMaterial,MinGoodCount,AddMaterialSkunoUser,AddMaterialSkunoDate) values('" & UCase(AddMaterial.Text) & "','" & UCase(MaterialDescription1.Text) & "','" & UCase(StorageSpaces1.Text) & "','" & 0 & "','" & 0 & "','" & 0 & "','" & UCase(loginUser) & "','" & Now & "')" 'Ucase()小寫轉化成大寫函數
TransactSQL (sql3)
MsgBox "料號新增成功,請新增下一個料號", 0, "恭喜!"
AddMaterial.Text = ""
MaterialDescription1.Text = ""
StorageSpaces1.Text = ""
AddMaterial.SetFocus
Exit Sub
End If
End If
End If
End If
End If
End If
End Sub
物料储位編號從000A,000B,000C.....199A,199B,199C;
以下SQL怎樣實現储位自動編號;Private Sub NewAdd_Click()
'2009.11.14
Dim sql3 As String
'判斷新增料號是否為空
If AddMaterial.Text = "" Then
MsgBox "新增料號1不能為空,請重新輸入新增料號!", 0, "提示!"
AddMaterial.SetFocus
Exit Sub
Else
'判斷料號長度是否符合規則
If Len(AddMaterial.Text) <> 8 And Len(AddMaterial.Text) <> 9 Then
MsgBox "輸入新增料號長度不符,請重新輸入新增料號!", 0, "提示!"
AddMaterial.Text = ""
AddMaterial.SetFocus
Exit Sub
Else
'判斷料號是否已經存在
sql3 = "select *from Material where MaterialSkuno='" & AddMaterial.Text & "'"
Set rs = TransactSQL(sql3)
If rs.EOF = False Then
MsgBox "輸入新增料號已經存在,請重新輸入新增料號!", 0, "提示"
AddMaterial.Text = ""
MaterialDescription1.Text = ""
StorageSpaces1.Text = ""
AddMaterial.SetFocus
Exit Sub
Else
'判斷物料描述是否為空
If MaterialDescription1.Text = "" Then
MsgBox "物料描述不能為空,請輸入物料描述!", 0, "提示!"
StorageSpaces1.Text = ""
MaterialDescription1.SetFocus
Exit Sub
Else
'判斷储位是否為空
If StorageSpaces1.Text = "" Then
MsgBox "储位不能為空,請輸入储位!", 0, "提示"
StorageSpaces1.SetFocus
Exit Sub
Else
'2009.11.15 新增
'判斷储位是否已經使用,如已經在使用,需重新分配储位 問題:怎樣實現储位自動編號
Dim sql6 As String
sql6 = "select *from Material where StorageSpaces='" & StorageSpaces1.Text & "'"
Set rs = TransactSQL(sql6)
If rs.EOF = False Then
MsgBox "該储位應經使用,請輸入另外的储位!", 0, "提示"
StorageSpaces1.Text = ""
StorageSpaces1.SetFocus
Exit Sub
Else
'插入料號到表"Material"
sql3 = "insert into Material(MaterialSkuno,MaterialDescription,StorageSpaces,GoodMaterial,FailMaterial,MinGoodCount,AddMaterialSkunoUser,AddMaterialSkunoDate) values('" & UCase(AddMaterial.Text) & "','" & UCase(MaterialDescription1.Text) & "','" & UCase(StorageSpaces1.Text) & "','" & 0 & "','" & 0 & "','" & 0 & "','" & UCase(loginUser) & "','" & Now & "')" 'Ucase()小寫轉化成大寫函數
TransactSQL (sql3)
MsgBox "料號新增成功,請新增下一個料號", 0, "恭喜!"
AddMaterial.Text = ""
MaterialDescription1.Text = ""
StorageSpaces1.Text = ""
AddMaterial.SetFocus
Exit Sub
End If
End If
End If
End If
End If
End If
End Sub
解决方案 »
- keyDown事件
- vb操作數據庫遇到的奇怪的問題,不知大家遇到過沒得?
- 不能加载空件TabDlg.SSTab
- VB程序当中,DAO生成的ACCESS数据库,如何更改字段的先后顺序?
- 我这句update怎么错了呢?
- 新手,刚学编程,刚学api不知道如何使用,为什么不对····在线急··············100分不要白不要,不够再加
- SourceSaft 问题!!
- DATA是不是不能和DATAGRID控件绑定?
- 請問怎樣用vb代碼將SQL數據庫中的几個表導入導出﹖
- 用VB6的报表设计器如何控制实现分页?
- 在线等:“对象变量或with块变量未设置”的错误
- VB复选框check的value属性找不到了
Dim I&
Private Sub Command1_Click()
'&HA = 10 &H199C = 6556
List1.Clear: List1.Visible = False
For I = 10 To 6556
List1.AddItem "&H" & String(4 - Len(Hex(I)), "0") & Hex(I)
Next I
List1.Visible = True
End Sub