Is or Is Not Null Function

nealaj

US Air Force
Local time
Today, 08:11
Joined
Mar 25, 2004
Messages
10
I have a form with multiple checkbox options available. I don't want the user to be able to continue to the next form without one of these options checked. There is a N/A option checkmark available as a minimum requirement to continue. I just can't get the code to work right for this. No matter whether items are checked or left blank, it lets the user continue to the next form.

Here is what I came up with so far... :confused:

If IsNull(A_.Value) Then
Resume
ElseIf IsNull(B_.Value) Then
Resume
ElseIf IsNull(C_.Value) Then
Resume
ElseIf IsNull(E_.Value) Then
Resume
ElseIf IsNull(N_A_.Value) Then
DoCmd.CancelEvent
Beep
MsgBox "One of these is required to be checked. If you do not require access to classified, please check the N/A box.", , "Classified"
N_A_.SetFocus


I've got the Else, DoCmd.RunMacro and End If functions correct, just need to know how to write this so it doesn't let a blank form be passed up.

Thanks,

Drew
 
If the user can only select one of these options then why not present them in a combobox instead?
 
Hi Drew,

Where are you coding that script? I pasted this from the A2K help on the Resume statement:
If you use a Resume statement anywhere except in an error-handling routine, an error occurs.

Do you want an Exit Sub instead of Resume?

Cheers,
Keith.
 
The user can choose multiple options, but because of the report that will print out at the end, it must be set up with multiple checkmarks instead of a combobox. I just need it so they choose at least one option before continuing to the next form.

Thanks,

Drew
 
Keith,

Not sure about the Exit Sub (which is in there at the end). If the first check is not marked, I want it to search through all available checks on the form to make sure at least one is checked before allowing the user to continue.

Thanks,

Drew
 
It's not the best method - it implies you have a repeating group in your table but anyway:

Put the code in the form's BeforeUpdate event

Code:
If chkA = False And chkB = False And chkC = False And ChkD = False Abd chkNA = False  Then
    Beep
    MsgBox "One of these is required to be checked. If you do not require access to classified, please check the N/A box.", , "Classified"
    chkNA.SetFocus
    Cancel = True
End If
 
It is as close as I have been to working how I am hoping for, but it still allows them to continue to the next form. If it matters, I am using a macro command in the "next" button (ie Close and OpenForm macro) to go to the next form. I need to prevent them from continuing to the next form before updating this one or it messes up my relationships.

I tried putting this command option in the button's module, but it kicks the message back no matter whether I have no options picked or all options picked and prevents me from moving on to the next form.

Thanks,

Drew
 
Although I'd much rather use a parent and child combination for such a procedure (or maybe a multi-select listbox and DAO) I'll give you this little example.
 

Attachments

Users who are viewing this thread

Back
Top Bottom