Test for Unchecked Checkbox in a query

dragonfly0802

Registered User.
Local time
Today, 17:28
Joined
Jan 28, 2010
Messages
13
Hello! I have a form that allows users to check boxes to select the Reports they would like to run. The checkboxes are named as follows:

chkReport1
chkReport2
chkReport3
chkReport4

I wrote a Macro that works perfectly to run the reports if the check box is selected. (there is a run button on the form that when clicked launches the macro).

Other users of the database accidentally leave the boxes unchecked sometimes so it has been requested that I include a Message box so if none of the checkboxes are selected, it returns a message box.

I can successfully test one box, when I insert the condition [chkReport1]=0 it works (the message box displays) however when I try to test all the boxes using the following condition nothing happens. I have no vba experience so I would need to know if there's a way to do this in a macro.

[chkReport1]=0 And [chkReport2]=0 And [chkReport3]=0 And [chkReport4]=0


Thank you so much for your time!!!
 
Try changing your ands to ors, see if that works
 
Thank you for replying. I can test with ors however the user may choose to run just one report so or would return the error message if they choose to run just one report :(
 
Well, you made it sound like all reports need to run and that users sometimes for got to check one. I don't understand why you need to do the check at all then, do you want them to respond yes or no to each check if it's zero? If that is the case do chk1=0 then msg box

chk2=0, then msg box

etc...
 
Sorry for the vague initial description :o but yes, I only need the message box to pop up if they forget to check at least one of the checkboxes. What happens is the users enter criteria and then forget to check a box for one of the 4 reports and sit there clicking the Run Reports button over and over again thinking that there is no data (I know I know) but they want me to have it pop up just a single message if they forgot to check at least one of the boxes. I hope this makes more sense now.

Thanks again for your time. It's greatly appreciated.
 
So a single message is what I told you already, I don't understand the problem with the ors, it will pop up one box. They then click ok or cancel depending on what they want to go back and change or leave it as is, if they purposely left some blank
 
After rereading your question, I think I understand better what you are trying to do. Where are you putting this code? Can you post your esact code, all of it?
 
The code is via a macro attached to the On Click Event of a button in the Form. The form has the 4 checkboxes for the reports

I've attached a document with the Macro Definition. The reports open fine, it's just when they haven't selected at least one of the checkboxes it won't display the message box.

I've tried using [chkReport1]=false And [chkReport2]=false and [chkReport3]=false and [chkReport4]=false to no avail.

Thank you!

moz-screenshot-2.png

moz-screenshot-1.png
 

Attachments

Hm, try it with -1, I don't know much about macros,

But you could probably do this easier with VBA instead of a macro.
 
Try make the code onClickEvent


Code:
if not (chkReport1 or chkReport2 or chkReport3 or chkReport4) then
'will entry if all off check box is false
    MsgBox "Your Message"
    Exit sub
endif

it works to me
 
Try make the code onClickEvent


Code:
if not (chkReport1 or chkReport2 or chkReport3 or chkReport4) then
'will entry if all off check box is false
    MsgBox "Your Message"
    Exit sub
endif

it works to me

That's what I was thinking of, but I didn't know about "If Not" THat's great and I hope it works for him.
 

Users who are viewing this thread

Back
Top Bottom