主题:求助!实时错误3021
Public combo As String
Private Sub Command1_Click(Index As Integer)
Dim ConStr As String
Dim cn As Connection
Dim rs As Recordset
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ttj02.Mdb"
cn.Open ConStr
cn.CursorLocation = adUseClient
rs.Open "Select * from zhuti", cn, adOpenStatic, adLockReadOnly
rs1.Open "Select * from keti", cn, adOpenStatic, adLockReadOnly
Dim s, o, level1, level2, depart1, depart2 As String
s = frmlogin.UserType
o = combo
rs2.Open "Select * From zhuti Where zhiwu= '" & s & "'", cn, adOpenStatic, adLockReadOnly
rs3.Open "Select * From keti Where ziliao= '" & o & "'", cn, adOpenStatic, adLockReadOnly
'level1 = "SELECT * FROM zhuti WHERE zhiwu='" & s & "'"
'level2 = "SELECT * FROM keti WHERE zhiliao='" & o & "'"
level1 = rs2("degree1")
level2 = rs3("degree1")
depart1 = rs2("bumen1")
depart2 = rs3("bumen1")
Do While Not rs.EOF
If depart1 <> depart2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
ElseIf level1 < level2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
If level1 >= level2 Then
MsgBox "你有权限!", vbExclamation + vbOKCancel, "提示"
Form2.Show
Unload Me
Exit Sub
End If
End If
Loop
rs.Close
rs1.Close
rs2.Close
rs3.Close
Set rs = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
Set rs3 = Nothing
End Sub
Private Sub Command2_Click(Index As Integer)
Dim ConStr As String
Dim cn As Connection
Dim rs As Recordset
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ttj02.Mdb"
cn.Open ConStr
cn.CursorLocation = adUseServer
rs.Open "Select * from zhuti", cn, adOpenStatic, adLockReadOnly
rs1.Open "Select * from keti", cn, adOpenStatic, adLockReadOnly
Dim s, o, level1, level2 As String
s = frmlogin.UserType
o = Form1.combo
rs2.Open "Select * From zhuti Where zhiwu= '" & s & "'", cn, adOpenStatic, adLockReadOnly
rs3.Open "Select * From keti Where ziliao= '" & o & "'", cn, adOpenStatic, adLockReadOnly
'level1 = "SELECT * FROM zhuti WHERE zhiwu='" & s & "'"
'level2 = "SELECT * FROM keti WHERE zhiliao='" & o & "'"
level1 = rs2("degree1")
level2 = rs3("degree1")
depart1 = rs2("bumen1")
depart2 = rs3("bumen1")
Do While Not rs.EOF
If depart1 <> depart2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
ElseIf level2 < level1 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
If level2 >= level1 Then
MsgBox "你有权限!", vbExclamation + vbOKCancel, "提示"
Form2.Show
Unload Me
Exit Sub
End If
End If
Loop
rs.Close
rs1.Close
rs2.Close
rs3.Close
Set rs = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
Set rs3 = Nothing
End Sub
Private Sub Form_Load()
With Combo2(0)
.AddItem "生产部交总经理资料"
.AddItem "生产部交经理资料"
.AddItem "生产部交主管资料"
.AddItem "生产部一般资料"
End With
With Combo3(1)
.AddItem "销售部交总经理资料"
.AddItem "销售部交经理资料"
.AddItem "销售部交主管资料"
.AddItem "销售部一般资料"
End With
With Combo4(2)
.AddItem "采购部交总经理资料"
.AddItem "采购部交经理资料"
.AddItem "采购部交主管资料"
.AddItem "采购部一般资料"
End With
With Combo5(3)
.AddItem "生产部交总经理资料"
.AddItem "生产部交经理资料"
.AddItem "生产部交主管资料"
.AddItem "生产部一般资料"
End With
combo = Left(Combo2(0).Text, 12)
combo = Left(Combo3(1).Text, 12)
combo = Left(Combo4(2).Text, 12)
combo = Left(Combo5(3).Text, 12)
End Sub
错误字段: level2 = rs3("degree1")
Private Sub Command1_Click(Index As Integer)
Dim ConStr As String
Dim cn As Connection
Dim rs As Recordset
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ttj02.Mdb"
cn.Open ConStr
cn.CursorLocation = adUseClient
rs.Open "Select * from zhuti", cn, adOpenStatic, adLockReadOnly
rs1.Open "Select * from keti", cn, adOpenStatic, adLockReadOnly
Dim s, o, level1, level2, depart1, depart2 As String
s = frmlogin.UserType
o = combo
rs2.Open "Select * From zhuti Where zhiwu= '" & s & "'", cn, adOpenStatic, adLockReadOnly
rs3.Open "Select * From keti Where ziliao= '" & o & "'", cn, adOpenStatic, adLockReadOnly
'level1 = "SELECT * FROM zhuti WHERE zhiwu='" & s & "'"
'level2 = "SELECT * FROM keti WHERE zhiliao='" & o & "'"
level1 = rs2("degree1")
level2 = rs3("degree1")
depart1 = rs2("bumen1")
depart2 = rs3("bumen1")
Do While Not rs.EOF
If depart1 <> depart2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
ElseIf level1 < level2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
If level1 >= level2 Then
MsgBox "你有权限!", vbExclamation + vbOKCancel, "提示"
Form2.Show
Unload Me
Exit Sub
End If
End If
Loop
rs.Close
rs1.Close
rs2.Close
rs3.Close
Set rs = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
Set rs3 = Nothing
End Sub
Private Sub Command2_Click(Index As Integer)
Dim ConStr As String
Dim cn As Connection
Dim rs As Recordset
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\ttj02.Mdb"
cn.Open ConStr
cn.CursorLocation = adUseServer
rs.Open "Select * from zhuti", cn, adOpenStatic, adLockReadOnly
rs1.Open "Select * from keti", cn, adOpenStatic, adLockReadOnly
Dim s, o, level1, level2 As String
s = frmlogin.UserType
o = Form1.combo
rs2.Open "Select * From zhuti Where zhiwu= '" & s & "'", cn, adOpenStatic, adLockReadOnly
rs3.Open "Select * From keti Where ziliao= '" & o & "'", cn, adOpenStatic, adLockReadOnly
'level1 = "SELECT * FROM zhuti WHERE zhiwu='" & s & "'"
'level2 = "SELECT * FROM keti WHERE zhiliao='" & o & "'"
level1 = rs2("degree1")
level2 = rs3("degree1")
depart1 = rs2("bumen1")
depart2 = rs3("bumen1")
Do While Not rs.EOF
If depart1 <> depart2 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
ElseIf level2 < level1 Then
MsgBox "你没有权限!", vbExclamation + vbOKCancel, "错误"
If level2 >= level1 Then
MsgBox "你有权限!", vbExclamation + vbOKCancel, "提示"
Form2.Show
Unload Me
Exit Sub
End If
End If
Loop
rs.Close
rs1.Close
rs2.Close
rs3.Close
Set rs = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
Set rs3 = Nothing
End Sub
Private Sub Form_Load()
With Combo2(0)
.AddItem "生产部交总经理资料"
.AddItem "生产部交经理资料"
.AddItem "生产部交主管资料"
.AddItem "生产部一般资料"
End With
With Combo3(1)
.AddItem "销售部交总经理资料"
.AddItem "销售部交经理资料"
.AddItem "销售部交主管资料"
.AddItem "销售部一般资料"
End With
With Combo4(2)
.AddItem "采购部交总经理资料"
.AddItem "采购部交经理资料"
.AddItem "采购部交主管资料"
.AddItem "采购部一般资料"
End With
With Combo5(3)
.AddItem "生产部交总经理资料"
.AddItem "生产部交经理资料"
.AddItem "生产部交主管资料"
.AddItem "生产部一般资料"
End With
combo = Left(Combo2(0).Text, 12)
combo = Left(Combo3(1).Text, 12)
combo = Left(Combo4(2).Text, 12)
combo = Left(Combo5(3).Text, 12)
End Sub
错误字段: level2 = rs3("degree1")