MsgBox如果Checkbox是IsNull [英] MsgBox if Checkbox IsNull

查看:59
本文介绍了MsgBox如果Checkbox是IsNull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题1:在Access 97中,我有一个带有

子表单(sbfrmPostVacDates)的表单(frmVacationWeeks)。子表单最多可以有33个记录

,每个记录有2个复选框,一个用于批准,一个用于

被拒绝。主管打开frmVacationWeeks并批准或

拒绝员工请求休假的日期。当

主管关闭frmVacationWeeks时,如果他没有点击

复选框来批准或拒绝某个日期,我想要一个消息框弹出

并告诉他你错过了批准或拒绝请求的日期!我尝试以下
,但收到错误消息 - 运行时错误2450

- 告诉我找不到frmVacationWeeks。有人可以朝正确的方向转向吗?


如果IsNull(表格![frmVacationWeeks]![sbfrmPostVacDates]。已批准)或

IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates] .Rejected)然后

MsgBox你错过了批准或拒绝请求的日期!,

vbOKOnly ,需要主管行动

否则

DoCmd.Close acForm,frmVacationWeeks

结束如果

问题2:如何禁止主管在单个记录中单击

批准和拒绝的复选框?


谢谢,

JD

Question 1: In Access 97, I have a form (frmVacationWeeks) with a
subform (sbfrmPostVacDates). The subform can have up to 33 records
and each record has 2 checkboxes, one for approved and one for
rejected. A supervisor opens frmVacationWeeks and either approves or
rejects dates the employee has requested for vacation. When the
supervisor closes frmVacationWeeks, if he has failed to click a
checkbox to approve or reject a date, I want a message box to pop up
and tell him "You missed approving or rejecting a requested date!" I
tried the following, but I get an error message - Run-time error 2450
- telling me that frmVacationWeeks cannot be found. Can someone steer
me in the right direction?

If IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates].Approved) Or
IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates].Rejected) Then
MsgBox "You missed approving or rejecting a requested date!",
vbOKOnly, "Supervisor Action Required"
Else
DoCmd.Close acForm, "frmVacationWeeks"
End If

Question 2: How can I disallow the supervisor from clicking both
approved and rejected checkboxes in a single record?

Thanks,
JD

推荐答案

您在哪里放置此代码?我们可能会移动它并进行一些小改动以使其工作,取决于以下答案。


你想让它检查吗?关闭表格之前的所有记录或检查每个记录为

主管移动到下一个记录?后者将无需返回所有未经检查的记录中的所有

,尽管您可以过滤表单以仅显示那些。

有几种方法可以禁止检查两个方框的主管。


1)将复选框放在一个选项组中,这样只允许在

时间选择一个。但是,每个复选框都没有值。相反,您将为选项组指定一个值

,指示选中哪个框。这通常用radio

按钮来完成。 (点)而不是复选框。复选框通常表示您可以选择其中任何一个或全部。


2)使用复选框设置为三重状态。这将在一个

复选框中给你Null,Yes和No。


3)使用只允许其中一个复选框的代码一次检查,基本上

模拟选项组。


-

Wayne Morgan

Microsoft Access MVP

< jd **** @ yahoo.com>在消息中写道

news:75 ************************** @ posting.google.c om ...
Where did you place this code? We may be able to move it and make a small change to get it
to work, depending on the following answer.

Do you want it to check all records before closing the form or check each record as the
Supervisor moves to the next record? The latter would save having to go back through all
of the unchecked records, although you could filter the form to show only those.
There are a few ways to disallow the supervisor from checking both boxes.

1) Place the check boxes in an option group, this will allow only one to be selected at a
time. However, you won''t have a value for each check box. Instead you will have one value
for the option group indicating which box is checked. This is usually done with "radio
buttons" (the dots) instead of check boxes. Check boxes usually indicate that you can
select any or all of them.

2) Use on check box set for "Triple State". This will give you Null, Yes, and No in one
check box.

3) Use code that will only allow one of the check boxes to be checked at a time, basically
simulating the option group.

--
Wayne Morgan
Microsoft Access MVP
<jd****@yahoo.com> wrote in message
news:75**************************@posting.google.c om...
问题1:在Access 97中,我有一个带有
子表单(sbfrmPostVacDates)的表单(frmVacationWeeks)。子表单最多可以有33个记录,每个记录有2个复选框,一个用于批准,一个用于
拒绝。主管打开frmVacationWeeks并批准或
拒绝员工请求休假的日期。当
主管关闭frmVacationWeeks时,如果他没有点击
复选框批准或拒绝日期,我想要一个消息框弹出
并告诉他你错过了批准或拒绝请求的日期!我尝试了以下内容,但是收到错误消息 - 运行时错误2450
- 告诉我找不到frmVacationWeeks。有人可以指导我朝着正确的方向前进吗?

如果是IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates]。已批准)或者
IsNull(Forms![frmVacationWeeks]![ sbfrmPostVacDates]。拒绝)然后
MsgBox你错过了批准或拒绝请求的日期!,
vbOKOnly,需要主管行动
其他
DoCmd.Close acForm ,frmVacationWeeks
结束如果

问题2:如何禁止主管在单个记录中单击已批准和拒绝的复选框?

谢谢,
JD
Question 1: In Access 97, I have a form (frmVacationWeeks) with a
subform (sbfrmPostVacDates). The subform can have up to 33 records
and each record has 2 checkboxes, one for approved and one for
rejected. A supervisor opens frmVacationWeeks and either approves or
rejects dates the employee has requested for vacation. When the
supervisor closes frmVacationWeeks, if he has failed to click a
checkbox to approve or reject a date, I want a message box to pop up
and tell him "You missed approving or rejecting a requested date!" I
tried the following, but I get an error message - Run-time error 2450
- telling me that frmVacationWeeks cannot be found. Can someone steer
me in the right direction?

If IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates].Approved) Or
IsNull(Forms![frmVacationWeeks]![sbfrmPostVacDates].Rejected) Then
MsgBox "You missed approving or rejecting a requested date!",
vbOKOnly, "Supervisor Action Required"
Else
DoCmd.Close acForm, "frmVacationWeeks"
End If

Question 2: How can I disallow the supervisor from clicking both
approved and rejected checkboxes in a single record?

Thanks,
JD



感谢您的回复。我试图在星期五给你回复

从家里回来,但我一直收到来自浏览器的错误消息。


Wayne Morgan <共*************************** @ hotmail.com>在消息新闻中写道:< pz ****************** @ newssvr31.news.prodigy。 com> ...
Thank you for your reply. I tried to respond back to you on Friday
from home, but I kept getting error messages from my browser.

"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<pz******************@newssvr31.news.prodigy. com>...
您在哪里放置此代码?根据以下答案,我们可能会移动它并进行一些小改动以使其工作。


我把代码放在子窗体的OnClose事件中。当我在主窗体的OnClose事件中尝试使用

时,我得到了运行时错误438 -

对象不支持此属性或方法。 />
您是否希望它在关闭表单之前检查所有记录,或者在
主管移动到下一条记录时检查每条记录?后者将节省必须返回所有未经检查的记录,尽管您可以过滤表单以仅显示那些。


我想在关闭表格之前检查所有记录。


有几种方法可以禁止主管检查这两个方框。

3)使用只允许一次检查其中一个复选框的代码,基本上模拟选项组。
Where did you place this code? We may be able to move it and make a small change to get it
to work, depending on the following answer.
I put the code in the OnClose event of the subform. When I tried it
in the OnClose event of the main form, I got Run-time error 438 -
Object doesn''t support this property or method.
Do you want it to check all records before closing the form or check each record as the
Supervisor moves to the next record? The latter would save having to go back through all
of the unchecked records, although you could filter the form to show only those.
I want to check all the records before closing the form.

There are a few ways to disallow the supervisor from checking both boxes.

3) Use code that will only allow one of the check boxes to be checked at a time, basically
simulating the option group.




我想以这种方式尝试。你可以在这个案例中向我提供用于

的代码吗?非常感谢您的帮助。


谢谢!

JD



I want to try it this way. Can you supply me with the code to use in
this case? Your help is very much appreciated.

Thanks!
JD


好的,检查一下所有关闭表单时,使用DCount查看其中一个字段是否为空或

False,如果是,则取消关闭。这将在

父(主)表单的OnUnload事件中完成。


如果DCount(*,TableName, [ApprovedField]<> True和[RejectedField]<> True")> 0

然后

MsgBox"您错过了批准或拒绝请求的日期!,vbOkOnly + vbInformation,

需要主管行动 ;

取消=真

否则

我!sbfrmPostBacDates.Form.FilterOn = False

结束如果

''此时你会过滤表单只显示那些记录

''其中两个复选框都是No或Null

''如果< ;>那么它是No或Null

Me!sbfrmPostBacDates.Form.Filter =" [ApprovedField]<> True和[RejectedField]<>确实

Me!sbfrmPostBacDates.Form.FilterOn = True

检查只检查一个复选框的代码将放在AfterUpdate中

每个复选框的事件。


在Rejected复选框''AfterUpdate

Me.Approved = Not Me.Rejected


并在Approved复选框中'AfterUpdate

Me.Rejected = Not Me.Approved


这会将另一个复选框设置为您刚检查的方框的相反值。

确保字段名称和控件名称不相同。如果字段名称为Rejected,则

然后将复选框命名为chkRejected。如果对两者都做了,那将改变上面的




Me.chkRejected = Not Me.chkApproved


-

Wayne Morgan

Microsoft Access MVP

< jd **** @ yahoo.com>在留言新闻中写道:75 ************************* @ posting.google.co m ...
Ok, to check them all when closing the form, use DCount to see if either field is Null or
False and if so then Cancel the close. This would be done in the OnUnload event of the
parent (main) form.

If DCount("*", "TableName", "[ApprovedField] <> True And [RejectedField] <> True") > 0
Then
MsgBox "You missed approving or rejecting a requested date!", vbOkOnly+vbInformation,
"Supervisor Action Required"
Cancel = True
Else
Me!sbfrmPostBacDates.Form.FilterOn = False
End If
''At this point you would filter the form to show only those records
''where both checkboxes are No or Null
''If <> True then it is No or Null
Me!sbfrmPostBacDates.Form.Filter = "[ApprovedField] <> True And [RejectedField] <> True"
Me!sbfrmPostBacDates.Form.FilterOn = True
The code to check that only one checkbox is checked would be placed in the AfterUpdate
event of each checkbox.

In the Rejected checkbox''s AfterUpdate
Me.Approved = Not Me.Rejected

And in the Approved checkbox''s AfterUpdate
Me.Rejected = Not Me.Approved

This will set the other checkbox to be the opposite value of the box you just checked.
Make sure the field name and control name aren''t the same. If the field name is Rejected,
then make the name of the checkbox chkRejected. If done to both, that would change the
above to

Me.chkRejected = Not Me.chkApproved

--
Wayne Morgan
Microsoft Access MVP
<jd****@yahoo.com> wrote in message news:75*************************@posting.google.co m...
谢谢你的回复。我试图在星期五回家给你回复
,但我一直收到来自我浏览器的错误信息。

Wayne Morgan <共*************************** @ hotmail.com>在消息中写道
Thank you for your reply. I tried to respond back to you on Friday
from home, but I kept getting error messages from my browser.

"Wayne Morgan" <co***************************@hotmail.com> wrote in message



news:< pz ****************** @ newssvr31.news.prodigy。 com> ...


news:<pz******************@newssvr31.news.prodigy. com>...

你在哪里放置这段代码?我们可能会移动它并对
做一个小改动让它工作,具体取决于以下答案。
Where did you place this code? We may be able to move it and make a small change to get it to work, depending on the following answer.



我把代码放在OnClose事件中子窗体。当我在主窗体的OnClose事件中尝试它时,我得到了运行时错误438 -
对象不支持这个属性或方法。



I put the code in the OnClose event of the subform. When I tried it
in the OnClose event of the main form, I got Run-time error 438 -
Object doesn''t support this property or method.

您是否希望它在关闭表单之前检查所有记录,或者将每条记录检查为
主管移动到下一条记录?后者可以省去所有未经检查的记录,但是你可以过滤表格只显示那些。
Do you want it to check all records before closing the form or check each record as the Supervisor moves to the next record? The latter would save having to go back through all of the unchecked records, although you could filter the form to show only those.



我想先查看所有记录关闭表格。



I want to check all the records before closing the form.

有几种方法可以禁止主管检查这两个框。

3)使用只允许的代码其中一个复选框一次要检查,
基本上模拟了选项组。
There are a few ways to disallow the supervisor from checking both boxes.

3) Use code that will only allow one of the check boxes to be checked at a time, basically simulating the option group.



我想这样试试。你可以提供我在这个案例中使用的代码吗?非常感谢您的帮助。

谢谢!
JD



I want to try it this way. Can you supply me with the code to use in
this case? Your help is very much appreciated.

Thanks!
JD



这篇关于MsgBox如果Checkbox是IsNull的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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