Date Part or Date Value

C

c8tz

I have a form such that there are labels for each of the month and the
control being a checkbox such that if a task is done in a particular
month, then the checkbox for this month is ticked.

I would like to add a textbox on this form and link it to a table such
that if the checkbox for ie. Jan is checked then the textbox should
show Jan-2008 if the year entered was 2008. This would then be stored
in a table to use for calculations later on.

Please help.
 
J

John W. Vinson

I have a form such that there are labels for each of the month and the
control being a checkbox such that if a task is done in a particular
month, then the checkbox for this month is ticked.

I would like to add a textbox on this form and link it to a table such
that if the checkbox for ie. Jan is checked then the textbox should
show Jan-2008 if the year entered was 2008. This would then be stored
in a table to use for calculations later on.

Please help.

What kind of calculations? The text string "jan-2008" looks like a date to
you, but NOT to Access; it's just a text string!

Also you have twelve checkboxes and only one date field. What do you want put
into the table if the user checks five of the checkboxes? Or do you want to
add a new record to the table for each check? What if the user does two or
three tasks in one month?

To store an actual Date/Time value in a table field (bound to the textbox) you
can add code to the checkbox's AfterUpdate event. For the January checkbox
(which I'll call chkJan) you could put code like

Private Sub chkJan_AfterUpdate()
If Me!chkJan ' did the user set it to True?
Me!txtDateDone = DateSerial(Year(Date), 1, 1)
End If
End Sub

Use 2, 1 for February, 3, 1 for March, ..., 12, 1 for December; the ending 1
puts the first day of the month into the date/time field. Note that as written
checking one checkbox will undo the effect of checking another, only the last
checked will be stored.

Any reason not to use a Calendar control to enter date data...???

John W. Vinson [MVP]
 

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