The notorious error message: Can't set value to NULL when CheckBox property = FALSE. (1 Viewer)

dawkirst

Registered User.
Local time
Today, 10:06
Joined
Sep 1, 2005
Messages
21
Hi,

My problem is this: Whenever I enter something into the form other than first choosing the date from the DateTimePicker's drop-down list, I get the notorious error message: Can't set value to NULL when CheckBox property = FALSE.

What I can conclude is that the DateTimePicker can seemingly not return a null value to the database. A possible solution was given at this site: http://www.dotnet247.com/247reference/msgs/54/270422.aspx

I however, have no idea how to apply this to my form.

Can anyone help?

Thanks ahead!
 
Last edited:

peterhentrich

New member
Local time
Today, 17:06
Joined
Dec 28, 2006
Messages
1
Cause and resolution

Well I hope you have worked out this error already. But for all those readers here is the solution:

Background:
The root cause is due to the "Checkbox" property in the "Other" section of the MS Date & Time Picker ActiveX control.
If this "CheckBox" property = "true" then a checkbox will appear inside the date control. In run-time mode, this checkbox determines whether the date control is enabled/disabled. Disabling the date control using this checkbox will give a null value.

Cause:
If the value of the "checkbox" property = "false" (default value), and a null value is attempted to be entered when a new record is created, the control spits out the specified error "Can't set value to NULL when CheckBox property = FALSE".

Resolution:
There are 3 ways to resolve this (as far as I know):
1. Set the "checkbox" property to "true"
2. Set the default value of the date field to a value e.g. #1/01/1901# or Now()
3. Unbind the date picker from the data source by deleting the text in the "ControlSource" property and write your own code in the Form_Current() and DatePickerControl_Change() events. You will need to set your default value and then retrieve/update your database values via code.
 

Users who are viewing this thread

Top Bottom