Question 1: In Access 97, I have a form (frmVacationWee ks) with a
subform (sbfrmPostVacDa tes). The subform can have up to 33 records
and each record has 2 checkboxes, one for approved and one for
rejected. A supervisor opens frmVacationWeek s and either approves or
rejects dates the employee has requested for vacation. When the
supervisor closes frmVacationWeek s, 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 frmVacationWeek s cannot be found. Can someone steer
me in the right direction?
If IsNull(Forms![frmVacationWeek s]![sbfrmPostVacDat es].Approved) Or
IsNull(Forms![frmVacationWeek s]![sbfrmPostVacDat es].Rejected) Then
MsgBox "You missed approving or rejecting a requested date!",
vbOKOnly, "Supervisor Action Required"
Else
DoCmd.Close acForm, "frmVacationWee ks"
End If
Question 2: How can I disallow the supervisor from clicking both
approved and rejected checkboxes in a single record?
Thanks,
JD 17 14126
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.c om> wrote in message
news:75******** *************** ***@posting.goo gle.com... Question 1: In Access 97, I have a form (frmVacationWee ks) with a subform (sbfrmPostVacDa tes). The subform can have up to 33 records and each record has 2 checkboxes, one for approved and one for rejected. A supervisor opens frmVacationWeek s and either approves or rejects dates the employee has requested for vacation. When the supervisor closes frmVacationWeek s, 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 frmVacationWeek s cannot be found. Can someone steer me in the right direction?
If IsNull(Forms![frmVacationWeek s]![sbfrmPostVacDat es].Approved) Or IsNull(Forms![frmVacationWeek s]![sbfrmPostVacDat es].Rejected) Then MsgBox "You missed approving or rejecting a requested date!", vbOKOnly, "Supervisor Action Required" Else DoCmd.Close acForm, "frmVacationWee ks" End If
Question 2: How can I disallow the supervisor from clicking both approved and rejected checkboxes in a single record?
Thanks, JD
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******* ***********@new ssvr31.news.pro digy.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.
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.
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
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+vbInfo rmation,
"Supervisor Action Required"
Cancel = True
Else
Me!sbfrmPostBac Dates.Form.Filt erOn = 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!sbfrmPostBac Dates.Form.Filt er = "[ApprovedField] <> True And [RejectedField] <> True"
Me!sbfrmPostBac Dates.Form.Filt erOn = 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.c om> wrote in message news:75******** *************** **@posting.goog le.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******* ***********@new ssvr31.news.pro digy.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.
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.
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
Thank you, Wayne. You are a great help!
JD
Wayne, I've run into a problem and I hope you'll help me with it. My
subform is based on a parameter query with an expression in the
criteria field that asks the user what year the vacation days are
scheduled in. When I use the code you gave me in the unload event of
my main form, I get the following un-numbered error message: "The
object doesn't contain the Automation object 'Enter year in which days
are scheduled.' You tried to run a Visual Basic procedure to set a
property or method for an object. However, the component doesn't make
the property or method available for Automation operations." When I
debug, the following line of code is highlighted: Me!sbfrmPostVac Dates.Form.Filt er = "[ApprovedField] <> True And [RejectedField] <> True"
I've been trying for a couple of days to figure this out for myself,
but I'm stumped. Please help!
Thanks,
JD
Wayne, something I just thought of...I need to give the supervisor the
option of closing the form without approving or rejecting a date just
in case he needs to look at a report of his department's days off
before doing so. So I need to say vbOKCancel instead of vbOKOnly in
the line of code below, close the form if he selects cancel and
proceed with the code if he selects OK.
"> If DCount("*", "TableName" , "[ApprovedField] <> True And
[RejectedField] <> True") > 0 Then MsgBox "You missed approving or rejecting a requested date!", vbOkOnly+vbInfo rmation, "Supervisor Action Required"
Thanks in advance!
JD
If DCount("*", "TableName" , "[ApprovedField] <> True And [RejectedField] <> True") > 0
Then
If MsgBox("You missed approving or rejecting a requested date!",
vbOkCancel+vbIn formation,
"Supervisor Action Required") = vbCancel Then Exit Sub
Cancel = True
Else
Me!sbfrmPostBac Dates.Form.Filt erOn = 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!sbfrmPostBac Dates.Form.Filt er = "[ApprovedField] <> True And [RejectedField] <> True"
Me!sbfrmPostBac Dates.Form.Filt erOn = True
--
Wayne Morgan
Microsoft Access MVP
<jd****@yahoo.c om> wrote in message
news:75******** *************** ***@posting.goo gle.com... Wayne, something I just thought of...I need to give the supervisor the option of closing the form without approving or rejecting a date just in case he needs to look at a report of his department's days off before doing so. So I need to say vbOKCancel instead of vbOKOnly in the line of code below, close the form if he selects cancel and proceed with the code if he selects OK.
"> If DCount("*", "TableName" , "[ApprovedField] <> True And [RejectedField] <> True") > 0 Then MsgBox "You missed approving or rejecting a requested date!",
vbOkOnly+vbInfo rmation, "Supervisor Action Required"
Thanks in advance! JD
The easiest way around this is probably going to be a pop-up form. When you open your
form, instead of the query asking for the input, the pop-up form would. The query would
then refer to the textboxes on the pop-up form for the parameter values.
Make a form with 2 textboxes and a label asking for the input. Have an Ok button and a
Cancel button. In the OnOpen event of your current main form you would open the pop-up
with the acDialog window mode argument. This will halt everything until you close or hide
the pop-up. If you choose the Cancel button, you would also tell the OnOpen code of the
main form to Cancel its opening. If you choose the Ok button, you would check the values
entered into the textboxes and, if valid, hide the pop-up (Me.Visible = False). The
parameters in the query would refer to these textboxes for their values, that way they
will still be there later when you filter the subform and hopefully you won't get prompted
then. Close the pop-up in the OnClose event of the main form.
--
Wayne Morgan
Microsoft Access MVP
<jd****@yahoo.c om> wrote in message
news:75******** *************** ***@posting.goo gle.com... Wayne, I've run into a problem and I hope you'll help me with it. My subform is based on a parameter query with an expression in the criteria field that asks the user what year the vacation days are scheduled in. When I use the code you gave me in the unload event of my main form, I get the following un-numbered error message: "The object doesn't contain the Automation object 'Enter year in which days are scheduled.' You tried to run a Visual Basic procedure to set a property or method for an object. However, the component doesn't make the property or method available for Automation operations." When I debug, the following line of code is highlighted:
Me!sbfrmPostVac Dates.Form.Filt er = "[ApprovedField] <> True And [RejectedField] <>
True" I've been trying for a couple of days to figure this out for myself, but I'm stumped. Please help!
Thanks, JD
Wayne, I'm sorry but I keep running into walls. What I've run into
now is when after the message comes up "You missed approving..." and
OK is clicked, the records are filtered showing the record he missed
plus the blank record that is generated in the query because, I
suppose, of the Autonumber field. Anyway, of course ApprovedField and
RejectedField are null in this record, so Access thinks he missed
approving or rejecting it. Is there any way I can make Access ignore
this blank record?
Thanks,
JD
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message news:<41******* ***********@new ssvr31.news.pro digy.com>... If DCount("*", "TableName" , "[ApprovedField] <> True And [RejectedField] <> True") > 0 Then If MsgBox("You missed approving or rejecting a requested date!", vbOkCancel+vbIn formation, "Supervisor Action Required") = vbCancel Then Exit Sub Cancel = True Else Me!sbfrmPostBac Dates.Form.Filt erOn = 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!sbfrmPostBac Dates.Form.Filt er = "[ApprovedField] <> True And [RejectedField] <> True" Me!sbfrmPostBac Dates.Form.Filt erOn = True -- Wayne Morgan Microsoft Access MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: js |
last post by:
Hi all,
I currently encounter a problem and it is urgent to me.
After calling the MsgBox.Show(), the message box is shown with non-modal
mode, what is the possible reason??? This only happen in the VB project,
works fine in C# project.
SystemModal and ApplicationModal MsgBoxStyle were all tried and there
was no help.
|
by: Kenny G |
last post by:
Reference the below sub: I can't get the message box to close and
therefore the user can't enter anything - Y or N in the
OralAntibiotics box. Your help is appreciated.
Private Sub OralAntibiotics_Enter()
If Me.TypeofSurgery <> "Colon Surgery" Then
DoCmd.GoToControl "AntibioticAllergy"
Else
MsgBox "Data Entry Is Required - Enter a Y or an N!",
vbCritical, UHS
|
by: Nu2ASP.NET |
last post by:
What I am trying to do is essentially 'flip' the bits, when the user
clicks in the checkbox. For example, if the CheckBox appears checked,
and the user un-checks it, I want the underlying data field to change
from a "1" to a "0" (and vica versa).
I have the bindings worked out, I just can't figure out how to do the
update.
Here is my source:
|
by: VJ |
last post by:
Is there a standard message box with a Checkbox..?, or do I have to write
one?
VJ
|
by: DP |
last post by:
hi,
i need a little help. i have two tables and 2 forms, one with a subform.
i have a 'fildID' in one of the subforms, and i have another table, which
has the film information, including a checkbox, if the film is available.
if i enter an id in the subform in filmid, how can i get the checkbox in
another form to become unchecked?? (to show that the film is unavailable)
| |
by: jimm.sander |
last post by:
Hello,
Problem: Im using isnull() in vbscript to determine if a field returned
from a ado object call is in fact null. The problem is when I use
isnull in anything other than a response.write() I get the following
error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the
requested name or ordinal.
|
by: lee123 |
last post by:
I have a form I have been working on and now I am almost done with it but there is just one thing I need to finish it that I can figure out. Well I have a questionnaire form with 50 questions and I want to have a msgbox display at the end of the questionnaire "failed" or "passed" when the users have finished the test. On this form I have text boxes with "correct' and "incorrect" and a text box for the total percentage of the correct. This is...
|
by: martin DH |
last post by:
Hello,
In a report, for every record, I would like a checkbox to appear checked if a certain field contains any value.
The field is Client_comments. (memo field)
I added a checkbox called CkComments and added the following vba to the report code.
Private Sub CkComments_Load()
If IsNull(Client_comments) = False Then
CkComments = True
Else CkComments = False
|
by: Dököll |
last post by:
Me again!
I have been battling this one for months. Wrote below to aid in getting certain subforms to hide once checkbox named Active is clicked. I am hoping to make the code work for Date fields that may be empty. I think i am going about it the wrong way:
Private Sub Active_BeforeUpdate(Cancel As Integer)
'On current event of main form
'Check if checkbox is selected
'then show or hide subform
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |