无法在子窗体上打开新记录 [英] can't open new record on subform

查看:97
本文介绍了无法在子窗体上打开新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨组,


我有一个3级的表单层次结构,如下:


- 主要

---- frmSubOrders1

------ frmSubOrderDetails1


订单明细是订单和订单的子表单是一个子表单Main。


我还有一个订单表格和订单明细表。


我在Main上有一个按钮,打开Orders按钮作为frmSubOrders1的.SourceObject。这是有效的。


我在组合框上有一个打开订单详情的事件。作为frmSubOrderDetails1的.SourceObject以类似的方式。这也有效。


我正在使用以下代码执行此操作,将焦点设置在子窗体上,并打开一个新的订单详细信息。使用默认的acActiveDataObject记录。这个炒锅。


Dim stDocName As String

stDocName =" Order Details"

Me.frmSubOrderDetails1.SourceObject = stDocName

Me.frmSubOrderDetails1.SetFocus

DoCmd.GoToRecord ,, acNewRec


但是...当我尝试使用以下语法时,它不起作用:


DoCmd.GoToRecord acDataForm,stDocName,acNewRec


我收到以下错误:


对象订单详情不开放。


我不知道为什么会发生这种情况......


有什么建议吗?

Oliver

解决方案


嗨组,


我有一个3级的表单层次结构,如下:


- 主要

---- frmSubOrders1

------ frmSubOrderDetails1


订单明细是订单和订单的子表单是Main的子表单。


我还有一个订单表格和订单明细表。


我在Main上有一个按钮,打开Orders按钮作为frmSubOrders1的.SourceObject。这是有效的。


我在组合框上有一个打开订单详情的事件。作为frmSubOrderDetails1的.SourceObject以类似的方式。这也有效。


我正在使用以下代码执行此操作,将焦点设置在子窗体上,并打开一个新的订单详细信息。使用默认的acActiveDataObject记录。这个炒锅。


Dim stDocName As String

stDocName =" Order Details"

Me.frmSubOrderDetails1.SourceObject = stDocName

Me.frmSubOrderDetails1.SetFocus

DoCmd.GoToRecord ,, acNewRec


但是...当我尝试使用以下语法时,它不起作用:


DoCmd.GoToRecord acDataForm,stDocName,acNewRec


我收到以下错误:


对象订单详情不开放。


我不知道为什么会发生这种情况......


有什么建议吗?

Oliver



Olivero,

表格和子表格之间引用的语法规则不同之处我们已经专注于你试图操纵的表单/子表单。请参阅以下链接。
http://www.mvps.org/access/ forms / frm0031.htm


如果您遵循指南,那么当您执行代码时,将转到sub2(OrderDetails)上的新记录的一般语法主要表格如下:


我!Subform1.Form!Subform2.Form!ControlName.SetFocu s

DoCmd.GoToRecord ,, acNewRec


将您的对象名称替换为一般语法,您的语法应该是:


我!frmSubOrders1.Form!frmSubOrderDetails1.Form.Set Focus

DoCmd.GoToRecord ,, acNewRec



Olivero,

表格之间引用的语法规则当你还没有专注于你想要操作的表单/子表单时,子表单是不同的。请参阅以下链接。
http://www.mvps.org/access/ forms / frm0031.htm


如果您遵循指南,那么当您执行代码时,将转到sub2(OrderDetails)上的新记录的一般语法主要表格如下:


我!Subform1.Form!Subform2.Form!ControlName.SetFocu s

DoCmd.GoToRecord ,, acNewRec


将您的对象名称替换为一般语法,您的语法应该是:


我!frmSubOrders1.Form!frmSubOrderDetails1.Form.Set Focus

DoCmd.GoToRecord ,, acNewRec



Puppydogbuddy,


感谢您的信息和快速回复。我会通过链接阅读并试一试。


新年快乐!


Oliver


Puppydogbuddy,


感谢您的信息和快速回复。我会通过链接阅读并试一试。


新年快乐!


Oliver


这样可行,我可以使用Sub1表单上的按钮转到我的Sub2表单中的新记录,但是当Sub2表单记录进入新记录时,所以Sub1表单记录...我需要Sub1表单记录保持原样,我希望Sub2表单记录进入新记录。这是因为每个订单可能有几个订单明细记录。


有什么建议吗?


Hi group,

I''ve got a 3 level hierarchy of forms, as such:

--Main
----frmSubOrders1
------frmSubOrderDetails1

Order Details is a subform of Orders and Orders is a subform of Main.

I also have an "Orders" table and an "Order Details" table.

I have a button on Main that opens "Orders" as the .SourceObject of frmSubOrders1. This works.

I have an event on a combo box that opens "Order Details" as the .SourceObject of frmSubOrderDetails1 in a similar fashion. This also works.

I''m using the following code to do this, set the focus on the subform, and open a new "Order Details" record using the default acActiveDataObject. This woks.

Dim stDocName As String
stDocName = "Order Details"
Me.frmSubOrderDetails1.SourceObject = stDocName
Me.frmSubOrderDetails1.SetFocus
DoCmd.GoToRecord , , acNewRec

BUT... when I try to use the following syntax, it doesn''t work:

DoCmd.GoToRecord acDataForm, stDocName, acNewRec

I get the following error:

The object "Order Details" isn''t open.

I can''t figure out why this is happening...

Any advice?

Oliver

解决方案

Hi group,

I''ve got a 3 level hierarchy of forms, as such:

--Main
----frmSubOrders1
------frmSubOrderDetails1

Order Details is a subform of Orders and Orders is a subform of Main.

I also have an "Orders" table and an "Order Details" table.

I have a button on Main that opens "Orders" as the .SourceObject of frmSubOrders1. This works.

I have an event on a combo box that opens "Order Details" as the .SourceObject of frmSubOrderDetails1 in a similar fashion. This also works.

I''m using the following code to do this, set the focus on the subform, and open a new "Order Details" record using the default acActiveDataObject. This woks.

Dim stDocName As String
stDocName = "Order Details"
Me.frmSubOrderDetails1.SourceObject = stDocName
Me.frmSubOrderDetails1.SetFocus
DoCmd.GoToRecord , , acNewRec

BUT... when I try to use the following syntax, it doesn''t work:

DoCmd.GoToRecord acDataForm, stDocName, acNewRec

I get the following error:

The object "Order Details" isn''t open.

I can''t figure out why this is happening...

Any advice?

Oliver

Olivero,
The syntax rules for referencing between forms and subforms are different when you don''t already have focus on the form/subform that you are trying to manipulate. See the following link.
http://www.mvps.org/access/forms/frm0031.htm

If you follow the guide, the general syntax to go to a new record on sub2 (the OrderDetails) when you are executing the code from the main form is as follows:

Me!Subform1.Form!Subform2.Form!ControlName.SetFocu s
DoCmd.GoToRecord , , acNewRec

Substituting your object names into the general syntax, your syntax should be:

Me!frmSubOrders1.Form!frmSubOrderDetails1.Form.Set Focus
DoCmd.GoToRecord , , acNewRec


Olivero,
The syntax rules for referencing between forms and subforms are different when you don''t already have focus on the form/subform that you are trying to manipulate. See the following link.
http://www.mvps.org/access/forms/frm0031.htm

If you follow the guide, the general syntax to go to a new record on sub2 (the OrderDetails) when you are executing the code from the main form is as follows:

Me!Subform1.Form!Subform2.Form!ControlName.SetFocu s
DoCmd.GoToRecord , , acNewRec

Substituting your object names into the general syntax, your syntax should be:

Me!frmSubOrders1.Form!frmSubOrderDetails1.Form.Set Focus
DoCmd.GoToRecord , , acNewRec


Puppydogbuddy,

Thanks for the info and the quick reply. I''ll read through the link and give it a shot.

Happy New Year!

Oliver


Puppydogbuddy,

Thanks for the info and the quick reply. I''ll read through the link and give it a shot.

Happy New Year!

Oliver

So that works and I''m able to go to a new record in my Sub2 form by using a button on the Sub1 form, but when then Sub2 form record advances to a new record, so does the Sub1 Form record... I need the Sub1 form record to stay where it is and I want the Sub2 form record to advance to a new record. This is because there may be several Order Detail records per order.

Any advice?


这篇关于无法在子窗体上打开新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆