Consulting

Results 1 to 5 of 5

Thread: Code to enforce a user to tick a checkbox. Can this be done?

  1. #1
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location

    Code to enforce a user to tick a checkbox. Can this be done?

    Is it possible to apply visual basic functionality restrictions on form that prompted the user with a pop info to ensure that all or a select few of check boxes were ticked before processing? Can this be done? If so, what would I have to do? If possible can you provide an example.....I have checkboxes on a questionnaire on access 2007 which are A,B,C,D,E.
    Thanks for your conributions

  2. #2
    I'm still a newbie, so can't answer your question with an example, but I am sure someone will.

    However, I can tell you that I am pretty sure that this is possible.

    Assuming, when that the processing starts when the user clicks on a button, then you would need to surround the line of code which starts the processing with an IF statement.

    User has pressed button so
    --If tick box A, and B and C and D are checked.
    ----Do the processing
    --Else
    ----Prompt the user with a reminder that he needs to tick the checkboxes

    This should give you an idea of what to look for on the net ( I.e how to check if a tick box is checked, where to put the code to run when a button is pressed, etc )

    Or, you could just try and make the processing run once all the necessary boxes are ticked ( dangerous in case of user mistakes )
    You could make the tick boxes already ticked by default, and the user has to untick them (again, danger of user mistake )
    You could try and hide the button needed to start the processing until all the necessary boxes have been ticked ( this would require a notification for the user, or they probably wouldn't know that a button would appear and complain that there is no way of continuing in the form )

    Just some info to get you started from someone in the same time zone as you, (and country apparently ), until other more knowledgeable and helpful people get involved.

  3. #3
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    Thanks!

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    It is fairly simple code an example would be

    if me.checkbox0 = 0 then msgbox "Please tick the Tickbox"

    Where checkbox0 is the actual name of your checkbox and you can replace tickbox in the message with the name of your tickbox.
    The code would go in the Command button that closes the form before the close statement and in the before close event procedure.

  5. #5
    VBAX Mentor
    Joined
    Aug 2010
    Posts
    457
    Location
    Thanks!

Posting Permissions

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