Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012

    Unanswered: mandatory checkbox

    I have a checkbox on my main form. This checkbox is to be mandatory on save and close. If this checkbox has not been checked then an error message is supplied and it goes to the field I assigned to setfocus. This does work on save. However if I go to close and the checkbox hasn't been checked then it will supply the error message then close. Does not go to the designated setfocus field. You can't setfocus to a checkbox right?

    Thanks in advance
    Kim P

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    I'm confused! What is the point of having a Checkbox Control that has to have one and only one given Value, i.e has to be equal to True/Yes/-1, before the Record can be saved?

    That aside, you have to Cancel the save before returning Focus to the Checkbox. in general terms, Validation code to check Controls before saving a Record should be something like this:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
     If Me.CheckboxName <> -1 Then
       MsgBox "CheckboxName Must Be Ticked Before Saving Record!"
       Cancel = True
       Exit Sub
     End If
    End Sub
    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts