我用一个datagrid控钮和一个button按钮 来实现浏览ACCESS数据库中表的记录
可是每当调用窗体的时候 不点button按钮 直接关闭 它就显示实时错误'3704',对象关闭时不允许操作 这是怎么回事啊
下面是我的代码 大家帮个忙看一下吧
Private Sub Command1_Click()
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Dim sqlall As String
'查询所有已录取信息,按院系,省份,总分排序
sqlall = "select * from 已录取考生表 order by 总分,院系,省份"
rs_all.CursorLocation = adUseClient
rs_all.Open sqlall, conn, adOpenStatic, adLockOptimistic
'若没有符合条件的记录则提示用户且退出
If rs_all.EOF = True Then
MsgBox "对不起,没有符合条件的记录!", vbOKOnly + vbInformation, "注意"
rs_all.Close
Exit Sub
End If
Set DataGrid1.DataSource = rs_all
DataGrid1.Refresh
End SubPrivate Sub Command2_Click()
CommonDialog1.ShowPrinterEnd SubPrivate Sub Command3_Click()
frmalladmit.Hide
End SubPrivate Sub Form_Load()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
End SubPrivate Sub Form_Unload(Cancel As Integer)
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
rs_all.Close
End Sub
可是每当调用窗体的时候 不点button按钮 直接关闭 它就显示实时错误'3704',对象关闭时不允许操作 这是怎么回事啊
下面是我的代码 大家帮个忙看一下吧
Private Sub Command1_Click()
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Dim sqlall As String
'查询所有已录取信息,按院系,省份,总分排序
sqlall = "select * from 已录取考生表 order by 总分,院系,省份"
rs_all.CursorLocation = adUseClient
rs_all.Open sqlall, conn, adOpenStatic, adLockOptimistic
'若没有符合条件的记录则提示用户且退出
If rs_all.EOF = True Then
MsgBox "对不起,没有符合条件的记录!", vbOKOnly + vbInformation, "注意"
rs_all.Close
Exit Sub
End If
Set DataGrid1.DataSource = rs_all
DataGrid1.Refresh
End SubPrivate Sub Command2_Click()
CommonDialog1.ShowPrinterEnd SubPrivate Sub Command3_Click()
frmalladmit.Hide
End SubPrivate Sub Form_Load()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
End SubPrivate Sub Form_Unload(Cancel As Integer)
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
rs_all.Close
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货