VB 对象打开时不允许操作:错误3705 第一打开窗体可以,第二次加载同一窗体时出错

PublicSubLoadListUser()readServerDimitmXAsListItemDimrsAsADODB.RecordsetSetrs=NewADOD... Public Sub LoadListUser()
readServer
Dim itmX As ListItem
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
List1.ListItems.Clear
sqlConnect cnMain, strSQLServer, strSQLUser, strSQLPW, strSQLDB
rs.Open "select * from PrintUser order by UserID", cnMain, 1, 1
If Not rs.EOF Then
Do While Not rs.EOF
Set itmX = List1.ListItems.Add(, , rs.Fields("UserName"))
With itmX
.SubItems(1) = IIf(IsNull(rs.Fields("UserDepartment")), "", rs.Fields("UserDepartment"))
.ListSubItems(1).ForeColor = vbBlue
.SubItems(2) = IIf(IsNull(rs.Fields("Userphone")), "", rs.Fields("Userphone"))
.SubItems(3) = IIf(IsNull(rs.Fields("UserEmail")), "", rs.Fields("UserEmail"))
.ListSubItems(3).ForeColor = vbRed
.SubItems(4) = IIf(IsNull(rs.Fields("UserGroup")), "", rs.Fields("UserGroup"))
.SubItems(5) = IIf(IsNull(rs.Fields("UserState")), "", rs.Fields("UserState"))
.SubItems(6) = IIf(IsNull(rs.Fields("userBTotalPages")), 0, rs.Fields("userBTotalPages"))
.ListSubItems(6).ForeColor = vbBlue
.SubItems(7) = IIf(IsNull(rs.Fields("userctotalpages")), 0, rs.Fields("userctotalpages"))
.ListSubItems(7).ForeColor = vbBlue
.SubItems(8) = Val(rs.Fields("usermoneytotal")) - (rs.Fields("userbtotalpages") * Val(rs.Fields("UserPriceBlack")))
If .SubItems(8) < 0 Then
FrmMain.LBSB(3).caption = "请及时充值!"
FrmMain.LBSB(3).ForeColor = vbRed
End If
.SubItems(9) = CDbl(IIf(IsNull(rs.Fields("UserBtotalPages")), 0, rs.Fields("UserBtotalPages"))) * CDbl(IIf(IsNull(rs.Fields("UserPriceBlack")), 0, rs.Fields("UserPriceBlack")))
.SubItems(10) = IIf(IsNull(rs.Fields("userGreatTime")), "", rs.Fields("userGreatTime"))
End With
rs.MoveNext
Loop
End If
End Sub

Private Sub Form_Load()
Me.WindowState = 2
LoadListUser

End Sub
搞定了,谢谢。
cnMain.close
展开
 我来答
zx001z7d53
2012-05-05 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5630万
展开全部
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
改为
Dim rs As New ADODB.Recordset
试试
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式