问题设置.OnClick事件 [英] Problem setting .OnClick event
问题描述
嗨
我的表格有140个标签。每个标签都有一个OnClick事件,
对于每个标签都不同。现在我想将表单用作另一种形式的
子表单。出于这个原因,我必须更改所有OnClick
事件。例如
= SetDate1([Forms]![frmCalendar]!btn1Tg11; 1)
nedds更改为
= SetDate1([表格] ]![frmOrder]![frmCalendar]!btn1Tg11; 1)
(" btn1Tg11"是每个事件发生变化的部分)
我写了下面的代码,但是我得到了一个运行时错误2438:你输入的
exssion包含无效的语法。我用的是A2K。任何想法?
(请原谅ugliy缩进。我使用谷歌小组写这个
消息,这个愚蠢的客户删除所有领先的空白......)
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k作为整数
Dim helpStr As String
DoCmd.OpenForm" frmCalendar",acDesign
for i = 1 To 3
对于j = 1到6
对于k = 1到7
使用表格![frmCalendar](" btn"& i& amp; ;Tg& j& k)
..Visible = True
helpStr" = SetDate1([Forms]![frmOrder]![frmCalendar] !btn"& i&
" Tg"& j& k&" ;; 1)"
..OnClick = helpStr
结束
下一个k
下一个j
下一个我
DoCmd.Close acForm ,frmCalendar,acSaveYes
结束子
使用Forms![frmCalendar](" btn" &安培;我和我" Tg的" &安培; j& k)
您可以尝试
使用Forms![frmCalendar] .Controls(" btn"& i&">& j& k)
< gg *** @ TerraTerra.ch>在消息中写道
news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
嗨
我有一张带有140个标签的表格。每个标签都有一个OnClick事件,
对于每个标签都不同。现在我想将表单用作其他表单的子表单。出于这个原因,我必须更改所有OnClick
事件。例如
= SetDate1([Forms]![frmCalendar]!btn1Tg11; 1)
nedds要更改为
= SetDate1([Forms]![frmOrder]![frmCalendar]!btn1Tg11; 1)
(btn1Tg11是每个事件更改的部分)
我编写了以下代码,但是我得到了运行时错误2438:
您输入的exssion包含无效语法。我用的是A2K。任何想法?
(请原谅ugliy缩进。我使用Google Groups写这个
消息,这个愚蠢的客户端删除所有领先的空白......)
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim helpStr As String
DoCmd.OpenForm" frmCalendar" ;,acDesign
对于i = 1到3
对于j = 1到6
对于k = 1到7
使用表格![frmCalendar](" btn"& i&Tg& j& k)
.Visible = True
helpStr" = SetDate1([Forms]![frmOrder]![frmCalendar]!btn"& i& ;
Tg& j& k&" ;; 1)"
.OnClick = helpStr
结束时
下一个k
下一个j
接下来我
DoCmd.Close acForm,frmCalendar,acSaveYes
嗨
感谢您的回答。但是你所指示的改变根本没有帮助
。
错误显示在行上
..OnClick = helpStr
OnClick Property和Visible
属性有什么区别吗?为.Visible分配一个新值可以正常工作,但是.OnClick
导致描述错误。
Walter
您好
我刚刚安装了对新闻组的替代访问权限。现在我能够发布格式化的代码(至少我希望如此)
Walter
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim helpStr As String
DoCmd.OpenForm" frmCalendar",acDesign
For i = 1 to 3
for j = 1 To 6
对于k = 1到7
使用表格![frmCalendar](" btn" i&">& j& k)
''关于下一行的陈述完美无缺;所以分配
属性有效!
.Visible = True
helpStr" = SetDate1([Forms]![frmOrder]![frmCalendar] !btn"& i&
" Tg"& j& k&" ;; 1)"
''下一行将提高错误
.OnClick = helpStr
结束
下一个k
下一个j
接下来我是
DoCmd.Close acForm,frmCalendar,acSaveYes
End Sub
Hi
I have a form with 140 labels. Each label has got an OnClick event that
is different for each of these labels. Now I want to use the form as a
subform of an other form. For this reason I have to change all OnClick
events. e.g
=SetDate1([Forms]! [frmCalendar]!btn1Tg11;1)
nedds to be changed to
= SetDate1([Forms]![frmOrder]![frmCalendar]!btn1Tg11;1)
("btn1Tg11" is the part that changes for each Event)
I wrote the following code, but I get a runtime error 2438: The
expession you entered contains invalid syntax. I use A2K. Any idea?
(Please excuse the ugliy indent. I use Google Groups to write this
message and this stupid client removes all leading blanks...)
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim helpStr As String
DoCmd.OpenForm "frmCalendar", acDesign
For i = 1 To 3
For j = 1 To 6
For k = 1 To 7
With Forms![frmCalendar]("btn" & i & "Tg" & j & k)
..Visible = True
helpStr "= SetDate1([Forms]![frmOrder]![frmCalendar]!btn" & i &
"Tg" & j & k & ";1)"
..OnClick = helpStr
End With
Next k
Next j
Next i
DoCmd.Close acForm, "frmCalendar", acSaveYes
End Sub
You didn''t say which line causes the error, but if it''s this one
With Forms![frmCalendar]("btn" & i & "Tg" & j & k)
You might try
With Forms![frmCalendar].Controls("btn" & i & "Tg" & j & k)
<gg***@TerraTerra.ch> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...Hi
I have a form with 140 labels. Each label has got an OnClick event that
is different for each of these labels. Now I want to use the form as a
subform of an other form. For this reason I have to change all OnClick
events. e.g
=SetDate1([Forms]! [frmCalendar]!btn1Tg11;1)
nedds to be changed to
= SetDate1([Forms]![frmOrder]![frmCalendar]!btn1Tg11;1)
("btn1Tg11" is the part that changes for each Event)
I wrote the following code, but I get a runtime error 2438: The
expession you entered contains invalid syntax. I use A2K. Any idea?
(Please excuse the ugliy indent. I use Google Groups to write this
message and this stupid client removes all leading blanks...)
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim helpStr As String
DoCmd.OpenForm "frmCalendar", acDesign
For i = 1 To 3
For j = 1 To 6
For k = 1 To 7
With Forms![frmCalendar]("btn" & i & "Tg" & j & k)
.Visible = True
helpStr "= SetDate1([Forms]![frmOrder]![frmCalendar]!btn" & i &
"Tg" & j & k & ";1)"
.OnClick = helpStr
End With
Next k
Next j
Next i
DoCmd.Close acForm, "frmCalendar", acSaveYes
End Sub
Hi
Thanks for your answer. However the your indicated change does not help
at all.
The error is shown on the line
..OnClick = helpStr
Is there any difference between the OnClick Property and the Visible
Property? Assigning a new value to .Visible works fine, but .OnClick
results in teh described error.
Walter
Hi
I just installed an alternative access to the newsgroup. Now I''m able to
post formatted code (at least I hope so)
Walter
Sub AdaptFormA()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim helpStr As String
DoCmd.OpenForm "frmCalendar", acDesign
For i = 1 To 3
For j = 1 To 6
For k = 1 To 7
With Forms![frmCalendar]("btn" & i & "Tg" & j & k)
'' statment on next line excutes perfectly; so assigning
properties works!
.Visible = True
helpStr "= SetDate1([Forms]![frmOrder]![frmCalendar]!btn" & i &
"Tg" & j & k & ";1)"
'' next line will raise the error
.OnClick = helpStr
End With
Next k
Next j
Next i
DoCmd.Close acForm, "frmCalendar", acSaveYes
End Sub
这篇关于问题设置.OnClick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!