使用选项按钮更改事件过程 [英] Using an option button to change an Event Procedure

查看:49
本文介绍了使用选项按钮更改事件过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上有一系列组合框,用于在DS视图中显示表单

(背后有一个qry)。这对我来说效果很好。

有些人喜欢在DS视图中查看数据,有些人在正常的表单视图中。

我知道他们可以选择更改,但是我试图让这个

尽可能方便用户(并为自己了解VBA)


所以我想我会用两个选项用于标识此选项的按钮

........一个用于表单视图,一个用于DS视图。一组按钮

可用于所有组合框


在组合框的更改事件过程中(一个示例

随附)可以通过将acFormDS或acNormal传递给

选项按钮中的代码来指定用于显示结果

表单的视图吗?


opForm =选项按钮,是或否(在更改时将opDatasheet变为

" no",opForm yo" yes")

opDataSheet =选项按钮,是或否(在更改时将opDatasheet

改为yes,opForm改为no)

当前VBA

Private Sub cmbPHP_Change()

DoCmd.OpenForm" frmPHP",acFormDS

DoCmd.Maximize

Me.cmbPHP ="

End Sub


建议的VBA(我可以这样做吗?它不起作用,所以看起来不行,但我

可能有错误的语法)

私人子cmbPHP_Change()

DoCmd.Ope nFormfrmPHP,IFF(opForm=是,acNormal,acFormMS)

DoCmd.Maximize

Me.cmbPHP ="" < br $>
结束子

谢谢Jerry

I have a series of comboboxes on a form that are used to display forms
in DS view (theres a qry behind it all). This is working well for me.
Some people like to see the data in DS view, some in normal form view.
I know they have the option to change that, but I trying to make this
as user friendly as possible (and to learn about VBA for myself)

So I thought I''d use two option buttons to identify this choice
........one for Forms view, one for DS view. One set of buttons that
could be used for ALL the comboboxes

In the on change event procedure for the combo boxes (one example
enclosed) can one specify which view to use to show the resultant
form by passing either acFormDS or acNormal to the code from the
option button?

opForm = option button, yes or no (on change turns opDatasheet to
"no", opForm yo "yes")
opDataSheet = option button, yes or no (on change turns opDatasheet
to "yes", opForm to "no")
Current VBA
Private Sub cmbPHP_Change()
DoCmd.OpenForm "frmPHP", acFormDS
DoCmd.Maximize
Me.cmbPHP = ""
End Sub

Proposed VBA (can I do this? it doesn''t work, so it seems not, but I
may have the syntax wrong)
Private Sub cmbPHP_Change()
DoCmd.OpenForm "frmPHP", IFF("opForm"="yes", acNormal, acFormMS)
DoCmd.Maximize
Me.cmbPHP = ""
End Sub
Thanks Jerry

推荐答案

-----开始PGP签名留言 - ----

哈希:SHA1


雅把我扔给了cmbPHP作为ComboBox的名称。 ComboBox前缀是

" cbo,"和cmb是一个CommandBar的前缀。


您应该将事件更改为AfterUpdate而不是OnChange''cuz

每次用户键入一个字符时,OnChange都会触发ComboBox。

当ComboBox的内容发生变化时,会触发AfterUpdate。有点

违反直觉,但这就是它的工作方式。


IIf()函数应该是这样的:


DoCmd.OpenForm" frmPHP",IIf(Me!opForm = True,acNormal,acFormDS)


-

MGFoster ::: mgf00< at> earthlink< decimal-point> net

奥克兰,加利福尼亚州(美国)


-----开始PGP SIGNATURE -----

版本: PGP个人隐私5.0

Charset:noconv

iQA / AwUBQ9aTkoechKqOuFEgEQJ + / wCgzICT1dOfZq4DlLxTNEPqJI2ATiYAnii9

/ gxVKxyPYHLxAw + af5SOZ7WH

= l7nz

-----结束PGP SIGNATURE -----
je ********* @ pioneer.com 写道:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ya threw me w/ "cmbPHP" as a ComboBox designation. ComboBox prefix is
"cbo," and "cmb" is the prefix for a CommandBar.

You should change the event to AfterUpdate instead of OnChange ''cuz
OnChange fires everytime the user types a character into the ComboBox.
AfterUpdate fires when the contents of the ComboBox have changed. Kinda
counterintuitive, but that''s how it works.

The IIf() function should be like this:

DoCmd.OpenForm "frmPHP", IIf(Me!opForm=True, acNormal, acFormDS)

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9aTkoechKqOuFEgEQJ+/wCgzICT1dOfZq4DlLxTNEPqJI2ATiYAnii9
/gxVKxyPYHLxAw+af5SOZ7WH
=l7nz
-----END PGP SIGNATURE-----
je*********@pioneer.com wrote:
我在表单上有一系列用于显示表单的组合框
在DS视图中(背后有一个qry)。这对我来说效果很好。
有些人喜欢在DS视图中查看数据,有些人喜欢正常的视图。
我知道他们可以选择改变它,但我试图让这个尽可能用户友好(并为自己了解VBA)

所以我想我会用两个选项按钮来识别这个选择
.......一个用于表单视图,一个用于DS视图。一组按钮可用于所有组合框

在组合框的更改事件过程中(一个示例
随附)可以指定使用哪个视图通过将acFormDS或acNormal传递给
选项按钮的代码来显示结果
表单?

opForm =选项按钮,是或否(在更改时将opDatasheet转换为
" no",opForm yo" yes")
opDataSheet =选项按钮,是或否(在更改时将opDatasheet转为是,opForm为no)

当前VBA
私人子cmbPHP_Change()
DoCmd.OpenForm" frmPHP",acFormDS
DoCmd.Maximize
Me.cmbPHP =""
结束子

建议的VBA(我可以这样做吗?它不起作用,所以看起来没有,但我可能有错误的语法)
Private Sub cmbPHP_Change()
DoCmd.OpenForm" frmPHP",IFF(" opForm" =" yes",acNormal,acFormMS)
DoCmd.Maximize
Me.cmbPHP =""
End Sub
I have a series of comboboxes on a form that are used to display forms
in DS view (theres a qry behind it all). This is working well for me.
Some people like to see the data in DS view, some in normal form view.
I know they have the option to change that, but I trying to make this
as user friendly as possible (and to learn about VBA for myself)

So I thought I''d use two option buttons to identify this choice
.......one for Forms view, one for DS view. One set of buttons that
could be used for ALL the comboboxes

In the on change event procedure for the combo boxes (one example
enclosed) can one specify which view to use to show the resultant
form by passing either acFormDS or acNormal to the code from the
option button?

opForm = option button, yes or no (on change turns opDatasheet to
"no", opForm yo "yes")
opDataSheet = option button, yes or no (on change turns opDatasheet
to "yes", opForm to "no")
Current VBA
Private Sub cmbPHP_Change()
DoCmd.OpenForm "frmPHP", acFormDS
DoCmd.Maximize
Me.cmbPHP = ""
End Sub

Proposed VBA (can I do this? it doesn''t work, so it seems not, but I
may have the syntax wrong)
Private Sub cmbPHP_Change()
DoCmd.OpenForm "frmPHP", IFF("opForm"="yes", acNormal, acFormMS)
DoCmd.Maximize
Me.cmbPHP = ""
End Sub



像魅力一样工作!!

感谢您的帮助。

我从一些教学

材料中获取了cmb用于组合框的功能。我没有那么多代码,我无法改变它。


Jerry


Worked like a charm !!
Thanks for the help.
I picked up the use of cmb for combobox from some instructional
materials. I don''t have so much code that I can''t change that.

Jerry


-----开始PGP签名的消息-----
哈希:SHA1
你把我扔给了cmbPHP作为ComboBox的名称。 ComboBox前缀是
cbo,和cmb是一个CommandBar的前缀。

你应该将事件更改为AfterUpdate而不是OnChange''cuz
每次用户在ComboBox中键入一个字符时,OnChange都会触发。
AfterUpdate触发当ComboBox的内容发生变化时。有点违反直觉,但这就是它的工作原理。

IIf()函数应该是这样的:

DoCmd.OpenFormfrmPHP, IIf(我!opForm = True,acNormal,acFormDS)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ya threw me w/ "cmbPHP" as a ComboBox designation. ComboBox prefix is
"cbo," and "cmb" is the prefix for a CommandBar.

You should change the event to AfterUpdate instead of OnChange ''cuz
OnChange fires everytime the user types a character into the ComboBox.
AfterUpdate fires when the contents of the ComboBox have changed. Kinda
counterintuitive, but that''s how it works.

The IIf() function should be like this:

DoCmd.OpenForm "frmPHP", IIf(Me!opForm=True, acNormal, acFormDS)



我有另一个问题。

我想要的DS打开最大化,但表格打开恢复的提示

通过同样的更新后事件


例子


DoCmd.OpenForm" frmPHP",IIf(Me!opForm = True,acNormal,acFormDS)

IIf(Me!opForm = True,Restore,Maximize)

(但是显然这两个判断没有任何联系,通过

时间到达IIf语句表格已经打开了)



我试过

DoCmd.OpenForm" frmPHP",IIf(Me!opForm = True,acNormal = Restore,

acFormDS = Maximize)

语法没有被标记,但无论opForm的状态如何,表单总是打开恢复



这应该是一个案例树,还是嵌套的IIf'?我还在

思考这个。


谢谢

Jerry
I have another question.
I''d like the DS to open maximized, but the form to open restored cued
by this same afterupdate event

example

DoCmd.OpenForm "frmPHP", IIf(Me!opForm=True, acNormal, acFormDS)
IIf(Me!opForm=True, Restore, Maximize)
(but obviously these two statments aren''t linked in any way, by the
time the IIf statement is reached the form is already opening)


I tried
DoCmd.OpenForm "frmPHP", IIf(Me!opForm=True, acNormal=Restore,
acFormDS = Maximize)
The syntax wasn''t flagged, but the form always opened up restored
regardless of the status of opForm
Should this be a case tree, or perhaps nested IIf''s? I''m still
pondering this.

Thanks
Jerry
DoCmd.OpenFormfrmPHP,IIf(Me!opForm = True,acNormal,acFormDS)
DoCmd.OpenForm "frmPHP", IIf(Me!opForm=True, acNormal, acFormDS)



这篇关于使用选项按钮更改事件过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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