标题:子母窗体连接问题“实时错误,对象已打开,不允许操作!”
取消只看楼主
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
结帖率:84.62%
 问题点数:0 回复次数:19 
子母窗体连接问题“实时错误,对象已打开,不允许操作!”
我在子窗体里书写
"Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub"
返回主窗体时,再打开该子窗体,却出现提示:

“实时错误,对象已打开,不允许操作!”

代码错哪呢?

再改为:
“Form1.Show
Me.Hide”

还是出现同样的错误提示!
搜索更多相关主题的帖子: 实时错误 窗体 子母 对象 Sub 
2006-10-28 12:31
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
COMMAND1在子窗体FORM2里的,主窗体是FORM1
2006-10-28 17:15
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
黄条覆盖在FORM3(密码窗体里)的代码:"Rst.CursorLocation = adUseClient"
2006-10-28 17:23
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
主窗体(FORM1)、子窗体(FORM2)COMMAND1在子窗体里面目的是返回主窗体的,
我在这COMMAND1里输入代码如下:

"Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub"

在主窗体里的进入子体FORM2的代码如下:

Private Sub Form_Load()
Form2.Show
Form1.Hide
End Sub

执行时,进入子体进入了,点COMMAND1时,也返回了主体,但再直接进入子体时,便出现了那个提示:

“实时错误,对象已打开,不允许操作!”

2006-10-28 18:39
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 

主窗体代码:
Private Sub cx_Click()
Form3.Show
Me.Hide
End Sub

Private Sub exit_Click()
End
End Sub

Private Sub Form_Load()
Form2.Show
Form1.Hide
End Sub

Private Sub qqxxbj_Click()
Unload Me

qqbj.Show

End Sub

Private Sub qqxxcx_Click()
qqcx.Show
Me.Hide
End Sub

其中一个子窗体(qqbj)代码:
Option Explicit
Private Conn As ADODB.Connection
Private Rst As New ADODB.Recordset

Private Sub CmdAdd_Click()
Text1.SetFocus

CmdDelete.Enabled = False
CmdPrevious.Enabled = False
CmdNext.Enabled = False
CmdFirst.Enabled = False
CmdLast.Enabled = False

'Set Rst = CreateObject("ADODB.Recordset")
If (Rst.State = adStateOpen) Then
Rst.Close
End If
Rst.CursorLocation = adUseClient
Rst.Open "Select * From 亲戚信息", Conn, adOpenKeyset, adLockPessimistic
Rst.AddNew
Rst.Fields("姓名").Value = Text1.Text
Rst.Fields("单位名称").Value = Text2.Text
Rst.Fields("办公电话").Value = Text3.Text
Rst.Fields("办公电话二").Value = Text4.Text
Rst.Fields("手机").Value = Text5.Text
Rst.Fields("手机二").Value = Text6.Text
Rst.Fields("宅电").Value = Text7.Text
Rst.Fields("宅电二").Value = Text8.Text

Rst.Fields("电子邮箱").Value = Text9.Text
Rst.Fields("电子邮箱二").Value = Text10.Text
Rst.Fields("QQ号").Value = Text11.Text
Rst.Fields("QQ号二").Value = Text12.Text
Rst.Fields("地址").Value = Text13.Text
Rst.Fields("邮政编码").Value = Text14.Text
Rst.Fields("其他").Value = Text15.Text
Rst.Update
MsgBox "添加成功"

CmdDelete.Enabled = True
CmdPrevious.Enabled = True
CmdNext.Enabled = True
CmdFirst.Enabled = True
CmdLast.Enabled = True
End Sub

Private Sub CmdDelete_Click()
CmdAdd.Enabled = False
CmdPrevious.Enabled = False
CmdNext.Enabled = False
CmdFirst.Enabled = False
CmdLast.Enabled = False



'Rst.CursorLocation = adUseClient
If MsgBox("要删除吗?", vbExclamation + vbYesNo) = vbYes Then
Rst.Delete
End If

MsgBox "删除成功"

CmdAdd.Enabled = True
CmdPrevious.Enabled = True
CmdNext.Enabled = True
CmdFirst.Enabled = True
CmdLast.Enabled = True
End Sub

Private Sub CmdFirst_Click()
Rst.MoveFirst
Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
End Sub

Private Sub CmdLast_Click()
Rst.MoveLast
Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
End Sub

Private Sub CmdNext_Click()
If (Not Rst.EOF) Then
Rst.MoveNext
If (Not Rst.EOF) Then
Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
Else
Rst.MoveLast
Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
MsgBox "这是最后一条记录!"
End If
End If
End Sub

Private Sub CmdPrevious_Click()

If (Not Rst.BOF) Then
Rst.MovePrevious
If (Not Rst.BOF) Then

Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
Else
Rst.MoveFirst
Text1.Text = Rst.Fields("姓名").Value
Text2.Text = Rst.Fields("单位名称").Value
Text3.Text = Rst.Fields("办公电话").Value
Text4.Text = Rst.Fields("办公电话二").Value
Text5.Text = Rst.Fields("手机").Value
Text6.Text = Rst.Fields("手机二").Value
Text7.Text = Rst.Fields("宅电").Value
Text8.Text = Rst.Fields("宅电二").Value

Text9.Text = Rst.Fields("电子邮箱").Value
Text10.Text = Rst.Fields("电子邮箱二").Value
Text11.Text = Rst.Fields("QQ号").Value
Text12.Text = Rst.Fields("QQ号二").Value
Text13.Text = Rst.Fields("地址").Value
Text14.Text = Rst.Fields("邮政编码").Value
Text15.Text = Rst.Fields("其他").Value
MsgBox "这是第一条记录!"
End If


End If
End Sub

Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub

Private Sub Form_Load()
Dim ConString As String
ConString = "Provider=Microsoft.Jet.OleDb.4.0;Persist Security Info = False;" _
& "Data Source =" & App.Path & "\db3.mdb"

Set Conn = CreateObject("ADODB.Connection")
With Conn
.ConnectionString = ConString
.Open
End With

Rst.CursorLocation = adUseClient
Rst.Open "Select * From 亲戚信息", Conn, adOpenKeyset, adLockPessimistic, adCmdText
End Sub

2006-10-28 21:58
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
怎么做呢?具体点,好么?
2006-10-29 12:53
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 

“Me.Visible = False”?

我添上试试!

2006-10-29 16:08
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
不行啊!
2006-10-29 16:11
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
我三个子体,其余两个“返回”控件功能均正常,就这一个!

代码一模一样的!!!!????
2006-10-29 16:23
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
“Unload Me '已经关闲了,不可能执行下面这一句了。
Form1.Show'已经关闲的窗口是不可能再运行这一句的。

反过来么?这样么?
“Form1.Show
Unload Me ”

试了试,还是不行!

还是,黄色条覆盖在密码登陆窗体上的:

“Rst.CursorLocation = adUseClient”
2006-10-29 23:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-99292-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.641679 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved