且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在另一个组合框中选择值后自动填充字段

更新时间:2023-01-07 22:25:17

" AA Arens" < BA *********** @ gmail.com>写在

新闻:11 ********************** @ i40g2000cwc.googlegr psps.com:
我有两张桌子,一张包括公司信息,如姓名和
电话号码。
另一张桌子,我必须填写联系人。
部分表格是选择他工作的公司(来自
列表框)。然后,在我选择了公司后,我希望自动填写第一张表中的现场电话号码。但是,
这就是为什么我想让它在表中得到满足(所以没有冗余):我希望可以编辑现场电话号码
因为公司电话号码是并不总是来自联系人的直接号码。

该方法应该是:
使用ComboBox进入公司并包含一个隐藏的

电话号码。在ComboBox的AfterUpdate事件中有代码...... Me.ContactPhone = Me.Company.Column(n)
...其中''n''是隐藏手机的零位置
组合框中的数字栏。

现在,我正处于该程序的中途。

我的问题:
如何设置在ContactPhone字段中。
在GotFocus或BeforeUpdate中,是否必须像
Me.ContactPhone = Len(我!ContactPhone)



你不要如果你想允许

更改它,那么在ContactPhone中什么都不需要。


如果你想在公司改变时防止改变它,并且

我不明白为什么你需要这样做,只需在更新后的组合框更新事件中添加条件




Company_AfterUpdate

IF len(me.Contactphone)& "" = 0然后

Me.ContactPhone = Me.Company.Column(n)

ENDIF


-

Bob Quintal


PA是我改变了我的电子邮件地址。


Bob Quintal写道:
如果你想改变它,你在ContactPhone中不需要任何东西。

如果你愿意的话为了防止在公司发生变化时更改它,并且
我看不出你为什么需要这样做,只需在更新后的组合框中为你的更新添加一个条件。
> Company_AfterUpdate
IF len(me.Contactphone)& "" = 0然后
Me.ContactPhone = Me.Company.Column(n)
ENDIF




一个小小的狡辩,鲍勃。

IF len(me.Contactphone)& "" = 0然后




我认为连接应该在括号内。


IF len(me.Contactphone& "")= 0然后


-

Randy Harris

tech at promail dot com

我很确定我知道我能记住的一切。


Randy Harris< pl **** @ send.no.spam>写在

新闻:Iz ****************** @ newssvr25.news.prodigy.n et:
Bob Quintal写道:


如果您希望
允许,您在ContactPhone中不需要任何内容要改变它。

如果你希望在公司改变时防止改变它,
我无法理解为什么你需要这样做,只需加上
条件你在组合框更新后的更新。

Company_AfterUpdate
IF len(me.Contactphone)& &QUOT;&QUOT; = 0然后
Me.ContactPhone = Me.Company.Column(n)
ENDIF



一个小狡辩,鲍勃。

IF len(me.Contactphone)& &QUOT;&QUOT; = 0然后



我认为串联应该在
括号内。

IF len(me.Contactphone&"" )= 0然后




我知道连接应该在括号内,

来自调试我一直在做的类似错误。


-

Bob Quintal


PA是我改变了我的电子邮件地址。


I have two tables, one consists of company info like name and phone
number.
Another table where I have to fill in the contact persons. Part of the
form is to choose the company he works for (From a list box). Then,
after I choosed the conpany, I want to have auto filled in the field
phone number from the 1st table. But, and that''s why i want to have it
archieved in the table (so no redundancy): I want that the field
phonenumber can be editted as the company phone number is not always
the direct number from the contact person.

The method should be like:
Use a ComboBox for entering the Company and include a hidden column
that has the
phone number. In the AfterUpdate event of the ComboBox have code...
Me.ContactPhone = Me.Company.Column(n)
....where ''n'' is the zero based position of the hidden phone number
column in the
ComboBox.

Now, I am halfway in that procedure.

My question:
How about the setting in the ContactPhone field.
Must it be like
Me.ContactPhone = Len(me!ContactPhone)
in GotFocus or BeforeUpdate?
Bart

"AA Arens" <ba***********@gmail.com> wrote in
news:11**********************@i40g2000cwc.googlegr oups.com:
I have two tables, one consists of company info like name and
phone number.
Another table where I have to fill in the contact persons.
Part of the form is to choose the company he works for (From a
list box). Then, after I choosed the conpany, I want to have
auto filled in the field phone number from the 1st table. But,
and that''s why i want to have it archieved in the table (so no
redundancy): I want that the field phonenumber can be editted
as the company phone number is not always the direct number
from the contact person.

The method should be like:
Use a ComboBox for entering the Company and include a hidden
column that has the
phone number. In the AfterUpdate event of the ComboBox have
code... Me.ContactPhone = Me.Company.Column(n)
...where ''n'' is the zero based position of the hidden phone
number column in the
ComboBox.

Now, I am halfway in that procedure.

My question:
How about the setting in the ContactPhone field.
Must it be like
Me.ContactPhone = Len(me!ContactPhone)
in GotFocus or BeforeUpdate?


You don''t need anything in the ContactPhone if you wish to allow
it to be changed.

If you wish to prevent changing it when the company changes, and
I cannot see why you would need to do that, just put a condition
on your update in the combobox After Update event.

Company_AfterUpdate
IF len(me.Contactphone) & "" = 0 Then
Me.ContactPhone = Me.Company.Column(n)
ENDIF

--
Bob Quintal

PA is y I''ve altered my email address.


Bob Quintal wrote:
You don''t need anything in the ContactPhone if you wish to allow
it to be changed.

If you wish to prevent changing it when the company changes, and
I cannot see why you would need to do that, just put a condition
on your update in the combobox After Update event.

Company_AfterUpdate
IF len(me.Contactphone) & "" = 0 Then
Me.ContactPhone = Me.Company.Column(n)
ENDIF



A minor quibble, Bob.
IF len(me.Contactphone) & "" = 0 Then



I think that the concatenation should be inside the parentheses.

IF len(me.Contactphone & "") = 0 Then

--
Randy Harris
tech at promail dot com
I''m pretty sure I know everything that I can remember.


Randy Harris <pl****@send.no.spam> wrote in
news:Iz******************@newssvr25.news.prodigy.n et:
Bob Quintal wrote:


You don''t need anything in the ContactPhone if you wish to
allow it to be changed.

If you wish to prevent changing it when the company changes,
and I cannot see why you would need to do that, just put a
condition on your update in the combobox After Update event.

Company_AfterUpdate
IF len(me.Contactphone) & "" = 0 Then
Me.ContactPhone = Me.Company.Column(n)
ENDIF



A minor quibble, Bob.

IF len(me.Contactphone) & "" = 0 Then



I think that the concatenation should be inside the
parentheses.

IF len(me.Contactphone & "") = 0 Then



I know that the concatenation should be inside the parentheses,
from debugging similar errors I keep making.

--
Bob Quintal

PA is y I''ve altered my email address.