|
本帖最后由 ty_1029 于 2014-11-11 17:08 编辑
第一个问题解决了 ,,第二个来了,代码如下,是一个选项卡的变更事件~
问题出在选择第二个选项,即If tabMain1.Value = 1 时,报错,要求对象(424错误),编辑器变黄的代码为:
rs.Open strSQL, cn, adOpenDynamic, adLockPessimistic
If tabMain1.Value = 0 or 2 时,正常。
- Private Sub tabMain1_Change()
- Dim cn As New ADODB.Connection
- Dim rs, rs1 As New ADODB.Recordset
- Dim strCn As String, strSQL, strSQL1 As String
- strCn = "Provider=sqloledb;Server=(local);Database=BY_CW;Uid=sa;Pwd=;"
- cn.Open strCn
-
- If tabMain1.Value = 0 Then
- Me.frmHeader!lblFormCaption1.Caption = Me.tabMain1.Pages(0).Caption
- Me.frmHeader!lblFormCaption2.Caption = Me.tabMain1.Pages(0).Caption
- End If
- If tabMain1.Value = 1 Then
- Dim j As Integer
- strSQL = "select * from BY_CW.dbo.usysRights where FSn<>0 order by FSn"
- rs.Open strSQL, cn, adOpenDynamic, adLockPessimistic
- rs.MoveFirst
- For j = 1 To 10
- Do While Not rs.EOF
- Me("Label" & j).Caption = rs!FUserID
- Me("T" & j).Value = rs!FRright
- Me("Te" & j).Value = rs!FRreadme
- j = j + 1
- rs.MoveNext
- Loop
- Next
- rs.Close
- Set rs = Nothing
- Me.frmHeader!lblFormCaption1.Caption = Me.tabMain1.Pages(1).Caption
- Me.frmHeader!lblFormCaption2.Caption = Me.tabMain1.Pages(1).Caption
- End If
- If tabMain1.Value = 2 Then
- Dim i As Integer
- strSQL1 = "select * from dbo.usysItems where FItemNumber=0 order by FGrouping"
- rs1.Open strSQL1, cn, adOpenDynamic, adLockPessimistic
- rs1.MoveFirst
- For i = 1 To 8
- Do While Not rs1.EOF
- Me("La" & i).Caption = rs1!Fid
- Me("Tc" & i).Value = rs1!FGrouping
- Me("Tc" & i).Visible = True
- Me("Tct" & i).Value = rs1!FItemText
- Me("Tct" & i).Visible = True
- i = i + 1
- rs1.MoveNext
- Loop
- Next
- rs1.Close
- Set rs1 = Nothing
- Me.frmHeader!lblFormCaption1.Caption = Me.tabMain1.Pages(2).Caption
- Me.frmHeader!lblFormCaption2.Caption = Me.tabMain1.Pages(2).Caption
- End If
- End Sub
复制代码
|
|