|
麻烦看一下代码哪里错了?
Private Sub CommandButton1_Click()
[d2] = ""
[f2] = ""
[b3] = ""
[e3] = ""
[f3] = ""
CommandButton2.Enabled = True
If [b2] <> "" Then
Else
[b2] = VBA.Date
End If
orderno = "'" & Format([b2], "yyMM") & Format(GetOrderNo([b2]), "00000")
[d2] = orderno
End Sub
Function GetOrderNo(dte As Date) As Integer
Dim cnn As New Connection
Dim rs As New Recordset
Dim sqlstr As String
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";Extended Properties=Excel 8.0"
.CursorLocation = adUseClient
.Open
End With
sqlstr = "select max(right([订单编号],5)) from [sheet2$a:f] where [订单日期]=#" & dte & "#"
rs.Open sqlstr, cnn
If Not rs.EOF And IsNull(rs.Fields(0)) = False Then
i = rs.Fields(0)
Else
i = 0
End If
GetOrderNo = i + 1
End Function
Private Sub CommandButton2_Click()
i = Sheet3.Range("a65536").End(xlUp).Row + 1
'MsgBox i
Sheet3.Range("a" & i) = [b2]
Sheet3.Range("b" & i) = [d2]
Sheet3.Range("c" & i) = [f2]
Sheet3.Range("d" & i) = [b3]
Sheet3.Range("e" & i) = [e3]
Sheet3.Range("f" & i) = [f3]
CommandButton2.Enabled = False
End Sub
Private Sub Worksheet_Activate()
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 5 Then
'MsgBox Target.Address
[b3] = Sheet2.Range("c:c").Find(Target.Value).Offset(0, -2).Value
'[e3] = Sheet2.Range("c:c").Find(Target.Value).Offset(0, -1).Value
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
测试显示一下内容
运行时错误“1004”
应用程序定义或对象定义错误
还有两个小要求
1,
设置权限。
1,开单员增加可以查看SHEET2的权限。
2,3个用户设置密码,密码不一样或可修改。
密码是12345 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|