PDA

View Full Version : Code to enforce a user to tick a checkbox. Can this be done?



wedd
11-10-2010, 12:27 AM
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:friends:

Frenchy646
11-10-2010, 02:07 AM
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.

wedd
11-10-2010, 05:58 AM
Thanks!

OBP
11-10-2010, 06:52 AM
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.

wedd
11-11-2010, 04:19 AM
Thanks!