将子窗体与Mainform同步 [英] Sync Subform with Mainform

查看:54
本文介绍了将子窗体与Mainform同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告知...


我目前有一个Mainform(客户)和一个Subform(服务

请求),具有一对多的关系(一个客户,多个服务

请求),每个客户都有一个唯一的客户ID,并且在子表单上自动填充了
。子表单包含一个名为TicketID

的字段(可能有多个实例,并且未在

的主表单上引用)。我希望能够输入TicketID,并且

让mainform导航到正确的客户。我有一个cmbbox

以下设置:


SELECT DISTINCT [服务记录]。[门票ID],[服务

记录] .CustomerID来自[服务记录];


马歇尔向有类似问题的人提出以下建议,

但我无法得到它上班。在Me.Recordset之后,FindFirst没有选项

,而且我不知道在[Serial] ="

部分中放入什么。感谢任何帮助。


好​​的,组合框是未绑定的,你希望它能够显示

主表单(导航到)的记录选择了

电脑。如果这是对你的

安排的正确理解,那么组合框'AfterUpdate

事件中的代码必须是这样的:


如果Serial是数字类型字段:

Me.Recordset.FindFirst" [Serial] =" &安培; Me.combobox

如果序列是文本字段:

Me.Recordset.FindFirst" [Serial] =""" &安培; Me.combobox& """"

解决方案

4月9日上午10:08,Robert Jacobs < robertjacob ... @ gmail.comwrote:


请指教...


我目前有一个Mainform(客户)和具有一对多关系(一个客户,多个服务

请求)的子表单(服务

请求),其中CustomerID对每个客户都是唯一的,并且是

在子表单上自动填充。子表单包含一个名为TicketID

的字段(可能有多个实例,并且未在

的主表单上引用)。我希望能够输入TicketID,并且

让mainform导航到正确的客户。我有一个cmbbox

以下设置:


SELECT DISTINCT [服务记录]。[门票ID],[服务

记录] .CustomerID来自[服务记录];


马歇尔向有类似问题的人提出以下建议,

但我无法得到它上班。在Me.Recordset之后,FindFirst没有选项

,而且我不知道在[Serial] ="

部分中放入什么。感谢任何帮助。


好​​的,组合框是未绑定的,你希望它能够显示

主表单(导航到)的记录选择了

电脑。如果这是对你的

安排的正确理解,那么组合框'AfterUpdate

事件中的代码必须是这样的:


如果Serial是数字类型字段:

Me.Recordset.FindFirst" [Serial] =" &安培; Me.combobox


如果序列是文本字段:

Me.Recordset.FindFirst" [Serial] =""" &安培; Me.combobox& """"



me.recordset ....指的是当前表格

如果你的组合框在子表单上,上面指的是子表单


me.parent.form.recordset ....会引用主窗体的'记录集


< blockquote> 4月9日上午11:34,lesperan ... @ natpro.com写道:


4月9日上午10点08分,Robert Jacobs ; < robertjacob ... @ gmail.comwrote:



请告知...


我目前有一个Mainform(客户)和一个Subform(服务

请求),有一对多的关系(一个客户,很多服务

请求)具有每个客户唯一的CustomerID,并且子窗体上自动填充了
。子表单包含一个名为TicketID

的字段(可能有多个实例,并且未在

的主表单上引用)。我希望能够输入TicketID,并且

让mainform导航到正确的客户。我有一个cmbbox

以下设置:


SELECT DISTINCT [服务记录]。[Ticket ID],[Service

记录] .CustomerID FROM [服务记录];


Marshall向有类似问题的人提出以下建议,

但是我无法让它工作。在Me.Recordset之后,FindFirst没有选项

,而且我不知道在[Serial] ="

部分中放入什么。任何帮助表示赞赏。


好​​的,组合框是未绑定的,你希望它能够显示

主表单(导航到)记录所选的

计算机。如果这是对你的

安排的正确理解,那么组合框'AfterUpdate

事件中的代码必须是这样的:


如果Serial是数字类型字段:

Me.Recordset.FindFirst" [Serial] =" &安培; Me.combobox


如果serial是文本字段:

Me.Recordset.FindFirst" [Serial] =" ;"" &安培; Me.combobox& """"



me.recordset ....指的是当前表格

如果你的组合框在子表单上,上面指的是子表单


me.parent.form.recordset ....会引用主窗体'的记录集 - 隐藏引用的文字 -


- 显示引用的文字 -



谢谢。组合框位于主窗体上,并指向子窗体。
当我输入me.recordset时
。我听到dun之类的声音然后它

并没有继续尝试自动填充FindFirst条目。如果我这样做的话,请给我一个b $ b me.parent。我得到了相同的声音,它不会一直填写

表格。我做错了什么,或者它应该这样做?

另外,我需要在[serial] ="中加入什么?上面的部分?


Robert Jacobs写道:


>我目前有一个Mainform (客户)和具有一对多关系(一个客户,多个服务请求)的子表单(服务
请求),其客户ID对每个客户都是唯一的,并且自动填写子窗体。子表单包含一个名为TicketID
的字段(可能有多个实例,并且根本没有在主表单上引用)。我希望能够输入TicketID并且
让mainform导航到正确的客户。我有一个cmbbox
以下设置:

SELECT DISTINCT [服务记录]。[票证ID],[服务
记录] .CustomerID FROM [服务记录]; 但是我无法让它发挥作用。在Me.Recordset之后,FindFirst没有选项,我不知道该怎么放在[Serial] ="
部分。感谢任何帮助。

好的,组合框是未绑定的,您希望它使
主窗体显示(导航到)所选
计算机的记录。如果这是对你的
安排的正确理解,那么组合框'AfterUpdate
事件中的代码需要是这样的:

如果Serial是一个数字类型字段:

Me.Recordset.FindFirst" [Serial] =" &安培; Me.combobox

如果序列是文本字段:

Me.Recordset.FindFirst" [Serial] =""" &安培; Me.combobox& """"



我无法理解你想要在这里发生的事情。

我想你想要主表格导航给客户。假设组合框'

BoundColumn设置为1,我想你会使用这种

语句:


Me.Recordset.FindFirst" CustomerID =" &安培; combobox.Column(1)


但是,如果你找到一个找不到方法的错误,它可能是

,因为表单使用的是ADO记录集而不是DAO

记录集。 ADO使用Find方法而不是FindFirst。


OTOH,您的主表单不应该加载所有客户

记录,这将是一个完全浪费资源。相反

表格应该打开,没有客户记录,只有在组合

框中做出选择后才加载

一个客户记录。


-

Marsh


Please advise...

I currently have a Mainform (Customers) and a Subform (Service
Requests) with a one to many relationship (one customer, many service
requests) with a CustomerID that is unique for each customer and is
autofilled on the subform. Subform contains field called TicketID
(which there could be multiple instances of and is not referenced on
the mainform at all). I want to be able to type in a TicketID and
have the mainform navigate to the correct customer. I have a cmbbox
with following setup:

SELECT DISTINCT [Service Records].[Ticket ID], [Service
Records].CustomerID FROM [Service Records];

Marshall gave the following advice to someone with a similar problem,
but I can''t get it to work. After Me.Recordset, there is no option
for FindFirst, and I don''t know what to put in the "[Serial]="
section. Any help is appreciated.

Ok, the combo box is unbound ans you want it to make the
main form display (navigate to) the record for the selected
computer. If that''s a correct understanding of your
arrangement, then the code in the combo box''s AfterUpdate
event needs to be something like this:

If Serial is a numeric type field:
Me.Recordset.FindFirst "[Serial]=" & Me.combobox
If serial is a Text field:
Me.Recordset.FindFirst "[Serial]=""" & Me.combobox & """"

解决方案

On Apr 9, 10:08 am, "Robert Jacobs" <robertjacob...@gmail.comwrote:

Please advise...

I currently have a Mainform (Customers) and a Subform (Service
Requests) with a one to many relationship (one customer, many service
requests) with a CustomerID that is unique for each customer and is
autofilled on the subform. Subform contains field called TicketID
(which there could be multiple instances of and is not referenced on
the mainform at all). I want to be able to type in a TicketID and
have the mainform navigate to the correct customer. I have a cmbbox
with following setup:

SELECT DISTINCT [Service Records].[Ticket ID], [Service
Records].CustomerID FROM [Service Records];

Marshall gave the following advice to someone with a similar problem,
but I can''t get it to work. After Me.Recordset, there is no option
for FindFirst, and I don''t know what to put in the "[Serial]="
section. Any help is appreciated.

Ok, the combo box is unbound ans you want it to make the
main form display (navigate to) the record for the selected
computer. If that''s a correct understanding of your
arrangement, then the code in the combo box''s AfterUpdate
event needs to be something like this:

If Serial is a numeric type field:
Me.Recordset.FindFirst "[Serial]=" & Me.combobox

If serial is a Text field:
Me.Recordset.FindFirst "[Serial]=""" & Me.combobox & """"

me.recordset.... refers to the current form
if your combobox is on the subform, the above refers to the subform

me.parent.form.recordset.... would refer to the main form''s recordset


On Apr 9, 11:34 am, lesperan...@natpro.com wrote:

On Apr 9, 10:08 am, "Robert Jacobs" <robertjacob...@gmail.comwrote:


Please advise...

I currently have a Mainform (Customers) and a Subform (Service
Requests) with a one to many relationship (one customer, many service
requests) with a CustomerID that is unique for each customer and is
autofilled on the subform. Subform contains field called TicketID
(which there could be multiple instances of and is not referenced on
the mainform at all). I want to be able to type in a TicketID and
have the mainform navigate to the correct customer. I have a cmbbox
with following setup:

SELECT DISTINCT [Service Records].[Ticket ID], [Service
Records].CustomerID FROM [Service Records];

Marshall gave the following advice to someone with a similar problem,
but I can''t get it to work. After Me.Recordset, there is no option
for FindFirst, and I don''t know what to put in the "[Serial]="
section. Any help is appreciated.

Ok, the combo box is unbound ans you want it to make the
main form display (navigate to) the record for the selected
computer. If that''s a correct understanding of your
arrangement, then the code in the combo box''s AfterUpdate
event needs to be something like this:

If Serial is a numeric type field:
Me.Recordset.FindFirst "[Serial]=" & Me.combobox

If serial is a Text field:
Me.Recordset.FindFirst "[Serial]=""" & Me.combobox & """"


me.recordset.... refers to the current form
if your combobox is on the subform, the above refers to the subform

me.parent.form.recordset.... would refer to the main form''s recordset- Hide quoted text -

- Show quoted text -

Thanks. The combobox is on the mainform, and refers to the subform.
when I type me.recordset. I hear a sound like "dun" and then it
doesn''t keep trying to autofill the FindFirst entry. If I do
me.parent. I get the same sound and it won''t keep filling the word
form. Am I doing something wrong, or is it supposed to do this?
Also, what do I need to put in the "[serial]="" section from above?


Robert Jacobs wrote:

>I currently have a Mainform (Customers) and a Subform (Service
Requests) with a one to many relationship (one customer, many service
requests) with a CustomerID that is unique for each customer and is
autofilled on the subform. Subform contains field called TicketID
(which there could be multiple instances of and is not referenced on
the mainform at all). I want to be able to type in a TicketID and
have the mainform navigate to the correct customer. I have a cmbbox
with following setup:

SELECT DISTINCT [Service Records].[Ticket ID], [Service
Records].CustomerID FROM [Service Records];

Marshall gave the following advice to someone with a similar problem,
but I can''t get it to work. After Me.Recordset, there is no option
for FindFirst, and I don''t know what to put in the "[Serial]="
section. Any help is appreciated.

Ok, the combo box is unbound ans you want it to make the
main form display (navigate to) the record for the selected
computer. If that''s a correct understanding of your
arrangement, then the code in the combo box''s AfterUpdate
event needs to be something like this:

If Serial is a numeric type field:
Me.Recordset.FindFirst "[Serial]=" & Me.combobox
If serial is a Text field:
Me.Recordset.FindFirst "[Serial]=""" & Me.combobox & """"


I am having trouble following what you want to happen here.
I think you want the main form to navigate to the customer
selected in the combo box. Assuming the combo box''s
BoundColumn is set to 1, I think you would use this kind of
statement:

Me.Recordset.FindFirst "CustomerID=" & combobox.Column(1)

But, if you get a method not found error, it''s probably
because the form is using an ADO recordset instead of a DAO
recordset. ADO uses the Find method instead of FindFirst.

OTOH, your main form should not be loading all the customer
records, which would be a gross waste of resources. Instead
the form should open with no customer records and only load
one customer record after a selection is made in the combo
box.

--
Marsh


这篇关于将子窗体与Mainform同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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