View Full Version : Now() function as default value for checkbox


barneskite
11-27-2008, 09:05 AM
Hi guys,
I'm new to this forum so please bear with me..
I'm designing a database to replace some paper based systems that generate a sequential number, used as an illustration control number (autonumber, primary key). I have made it so that the user generates a new number through a DAP - which works fine. The next part of the function that i need is to create a DAP to update the amendment details of each illustration by filtering (the same table) against the primary key.
Now the way i chose to do it is have a group filter control to select the record, and a checkbox bound to a date field. So when the user selects the record, he checks the appropriate box on the DAP and saves the record, which stamps the coresponding field with a date and time. I have used the Now() function as the default value for the checkbox, but when i save it records a date of 29/12/1859 ???? And no time??
Please help me because i'm stumbling my way through access at the moment, teaching myself by addressing real scenarios lol.
Thanks very much in anticipation

Tim Barnes.

Pat Hartman
11-27-2008, 05:29 PM
it is saving it as 31/12/1899 or 30/12/1899 depending on whether the value is 0 or -1. Checkboxes are assumed to be boolean values. If you want a date, use a date field. If you want a checkbox to control generating a date, use an unbound checkbox to place a value in the bound date field. Why not just put the date/time in automatically when it is required? Why make the user check a box?

John Big Booty
11-27-2008, 07:34 PM
If you wish to see the time you will need to set you controls format property to General Date, with any of the other date formats you will only see the Date not the time.

barneskite
11-27-2008, 11:25 PM
Thanks i'll try that. I'm using a checkbox to simulate 'milestones'. A single record can have different milestones completed at different times, so thats why i was trying to use a checkbox with the date value assigned

barneskite
11-28-2008, 12:45 AM
I have tried your suggestion, but i still cant seem to get it working...

I am an access newbie so i'm probably not doing it right.

I tried to bind an option group to the date feild, then put an unbound checkbox inside, but i cant seem to get the checkbox to be selectable then... what am i doing wrong? I dont know anything about VB so i am in the dark if it comes to scripting. My fields go like this,
checking author1 , AuthOKdate1 , Checking illust1 , IllustOKdate1 , checking author2 , AuthOKdate2 , Checking illust2 , IllustOKdate2 ,
The 'OKdate' feilds are the ones i would like to be populated by the date of the checkbox update.

neileg
11-28-2008, 04:47 AM
Listen very carefully, I will say this only once. You can't save a date in a check box. A check box only holds two values - true or false. This is stores as 0 or -1. When you format 0 or -1 as a date you get 31/12/1899 or 30/12/1899. This is what Pat told you in post 2.

Pat Hartman
11-30-2008, 07:19 PM
You need to use two separate fields. An unbound checkbox and a bound date field. The date field can be hidden if you don't want to see it. You need code in two places to manage the checkbox because it is unbound.

In the AfterUpdate event of the checkbox --
Me.DateField = Now()

In the Current event of the form --
If IsDate(Me.DateField) Then
Me.CheckboxField = true
Else
Me.CheckboxField = False
End IF

barneskite
12-01-2008, 03:04 AM
Listen very carefully, I will say this only once. You can't save a date in a check box. A check box only holds two values - true or false. This is stores as 0 or -1. When you format 0 or -1 as a date you get 31/12/1899 or 30/12/1899. This is what Pat told you in post 2.
Yeah thanks i got that the first time round ha ha ha

Right thanks Pat, i will try and do that today