3704 对象关闭时,不充许新的操作
1、在MSFlexGrid1列表中单右键,弹出“修改设备信息”,选择“修改设备信息”修改设备信息代码:
Private Sub Change_Equ_Click()
flag = 2
If FrmResult.MSFlexGrid1.Row > 0 Then
gSQL = " select * from EquInfo where EqID ='" & Trim(FrmResult.MSFlexGrid1.TextMatrix(FrmResult.MSFlexGrid1.Row, 6)) & "'"
Re_Equ.Show
Re_Equ.ZOrder 0
Else
MsgBox "目前没有设备信息,请先添加设备信息!", vbOKOnly + vbExclamation, "警告"
flag = 1
FrmStuff_info.Show
End If
End Sub
2 、第二步应该弹出要修改的设备信息,结果总是提示:3704 对象关闭时,不充许新的操作。
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim sql As String
Dim init() As String
Dim addNewRecord() As String
Bankname.ListIndex = 0
'Equ_Type.ListIndex = 0
'Equ_Dep.ListIndex = 0
'Equ_Name.ListIndex = 0
Set rs = TransactSQL(gSQL)
If rs.EOF = False Then ***** 提示总是在这个地方*****
With rs
Me.Equ_Num = rs(0)
Me.Bankname = rs(1)
Me.Equ_Type = rs(2)
Me.Equ_Name = rs(3)
Me.Equ_Logo = rs(4)
Me.Equ_Mode = rs(5)
Me.Equ_ID = rs(6)
Me.Equ_ByTm = rs(7)
Me.Equ_Time = rs(8)
Me.Equ_Dep = rs(9)
Me.Equ_Val = rs(10)
Me.Equ_Rem = rs(11)
'rs.Close
End With
' rs.Close
Me.Equ_Type.Enabled = False
Me.Equ_Num.Enabled = False
Me.Equ_Name.Enabled = False
Me.Equ_Logo.Enabled = False
Me.Equ_Mode.Enabled = False
Me.Equ_ID.Enabled = False
Me.Equ_ByTm.Enabled = False
Me.Equ_Dep.Enabled = False
Me.Equ_Val.Enabled = False
' rs.Close
End If
rs.Close
End Sub
3、我的模块代码
Public gUserName As String '保存用户名称
Public gSQL As String '保存SQL
Public flag As String '添加和修改标志
Public iflag As Integer '数据库是否打开标志
Public Function TransactSQL(ByVal sql As String) As ADODB.Recordset
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim srtConnection As String
Dim strArray() As String
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
On Error GoTo TransactSQL_Error
strConnection = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\Equ.mdb"
strArray = Split(sql)
con.Open strConnection
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
rs.Open Trim$(sql), con, adOpenKeyset, adLockOptimistic
Set TransactSQL = rs
iflag = 1
Else
con.Execute sql
iflag = 1
End If
TransactSQL_Exit:
Set rs = Nothing
Set con = Nothing
Exit Function
TransactSQL_Error:
MsgBox "查询错误11:" & Err.Description
iflag = 2
Resume TransactSQL_Exit
End Function
Public Sub TabToEnter(Key As Integer)
If Key = 13 Then
sendkdys "{TAB}"
End If
End Sub
Sub main()
Dim fLogin As New FrmLogin
fLogin.Show
End Sub
请高手指点,请问是不是我数据库联接不对,我能正常的登陆,查询等,但是要是数据库里没有东西,再查询的话也报这个错,当然位置不是在这里
全部内容.rar
(73.85 KB)
我把我的代码传上来了,请大家帮个忙。[ 本帖最后由 hsbwp1314 于 2010-10-11 09:20 编辑 ]