Before insert and check box and subform

A

a

Thank You
I have subform and form (Master form)
The Master Form Contain Check box name checkbox1
the subform is (data sheet) and allow addition = true
In the subform before insert event I try all the next code but not work
correct I want prevent user from data entery until check box = true or
checked
why all of this code not work???
====================
(1)
If Parent.checkbox1.Value = False Then
Cancel = True
Else
'
End If
============
(2)
If Parent.checkbox1.Value = 0 Then
Cancel = True
Else
'
End If
===================
(3)
If Me.Parent.checkbox1.Value = 0 Then
Cancel = True
Else
'
End If
========================
Why all this code not work correctly
 
J

Jeanette Cunningham

Try setting the subform's Data Entry to Yes (property dialog, data tab)

Jeanette Cunningham
 
D

Dirk Goldgar

a said:
Thank You
I have subform and form (Master form)
The Master Form Contain Check box name checkbox1
the subform is (data sheet) and allow addition = true
In the subform before insert event I try all the next code but not work
correct I want prevent user from data entery until check box = true or
checked
why all of this code not work???
====================
(1)
If Parent.checkbox1.Value = False Then
Cancel = True
Else
'
End If
============
(2)
If Parent.checkbox1.Value = 0 Then
Cancel = True
Else
'
End If
===================
(3)
If Me.Parent.checkbox1.Value = 0 Then
Cancel = True
Else
'
End If
========================
Why all this code not work correctly


In principle, all of these should work, and do in a test form I set up. Is
checkbox1 a bound control, or unbound? Is it actually False when you test
the code, or is it possible that it is Null (looking rather gray instead of
white)? What happens if you check it and then un-check it, and then try to
add a record in the subform?
 
A

a

Thank Mr
Dirk Goldgar
About Your Reply And Help

The Code work when assign defult value to checkbox1 to 0
 
D

Dirk Goldgar

a said:
Thank Mr
Dirk Goldgar
About Your Reply And Help

You're welcome.
The Code work when assign defult value to checkbox1 to 0

That implies that the checkbox was Null before, and that's why the code
wasn't working. I trust that your fix has corrected the problem. If not,
write back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top