1

I have created a userform and added a chekcbox called 'DSSSContact'. I have written some code to check the contents of the userform before saving in the following sub:

Private Sub SaveandClose_Click()

When the form is initialized the checkbox is set greyed out but ticked - which I think means the value is null. The SavandClose sub code includes the following which I thought would make sure that checkbox is either set to true or false:

If DSSSContact = Null Then
MsgBox "DSSS Contact Test"
Exit Sub
End If

However when I save and close the form using the save and close command button without having made a selection on the checkbox the form saves the contents without triggering the message box. All the other checks that I have created to verify that textboxes and combo boxes are populated are working fine. I have also added the following code within the same sub:

Debug.Print Me.DSSSContact.Value

This prints null in the Immediate window

Any help much appreciated. Thanks

2 Answers 2

1

Try

If IsNull(DSSSContact.Value) Then
Sign up to request clarification or add additional context in comments.

Comments

0

Check boxes in the forms are True = checked or False = Unchecked.

sub test()
    MsgBox DSSSContact.Value
    If DSSSContact.Value = "False" Then
    MsgBox "DSSS Contact Test"
    Exit Sub
    End If

end sub

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.