Re: Checkbox (default to no) - must be checked before saving/exiting

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mon, 26 Oct 2009 06:21:02 -0700, nicolam1980
<nicolam1980@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

The appropriate place to make this check is in Form_BeforeUpdate,
because you can set Cancel=True which prevents user from leaving the
form.
if me.myCheckbox1.value = false
or me.myCheckbox2.value = false
or me.myCheckbox3.value = false
then Cancel = True

If you literally mean "all checkboxes" you could alternatively write:
dim ctl as control
for each ctl in me.controls
if typeof(ctl) is checkbox then
if ctl.Value = false then
Cancel = True
Exit For
end if
end if
next

(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP


Hi

I have a feeling this might be a basic question but am new to access so
please be patient!!

I am creating a database for a team at work to use instead of paper
checklists. One such section I am creating concerns priority checks - I have
Yes/No boxes on the form that are defaulted to No.

I need to ensure people cannot save a record or exit the DB if any of these
boxes are left unchecked - can anyone help?

Thanks

Nicola
.



Relevant Pages

  • Re: Changing Checkbox status to active
    ... Doug Steele, Microsoft Access MVP ... > I have a form that has different objects on it, combo boxes, text boxes, ... What i need to do is have the checkboxes be inactive ...
    (microsoft.public.access.formscoding)
  • Re: Different data shown based on user input
    ... my advice changes with the info that there are over 200 checkboxes. ... I suggest you use combo boxes. ... Dim strStub As String ...
    (microsoft.public.access.queries)
  • Re: To check all items in a subform
    ... Microsoft Access MVP ... Try a Refresh just before you run the query. ... AND on the subform too... ... Assuming the subform checkboxes are True/False Boolean... ...
    (microsoft.public.access.forms)
  • RE: Checking for null fields before running query
    ... Dave Hargis, Microsoft Access MVP ... return at least one record when all 3 controls have values. ... 3 cbo boxes, 2 buttons, 12 txt fields. ... the cboboxes provide parameters for a query, and also criteria for 12 DSum ...
    (microsoft.public.access.modulesdaovba)
  • Re: Different data shown based on user input
    ... A form that knows which check boxes have been checked can be created like ... --check only one check box and observe that the other checkboxes are ... The basic process is to build the query using the fields that have been ... Dim strStub as String ...
    (microsoft.public.access.queries)