Checkbox linked to a date

Beanka Behrens
Beanka Behrens used Ask the Experts™
on
Hi I am workin with MS Access .
 I have a checkbox called " Gedowload" . I would like it if i checked the checkbox the date should apear in a colum " Datum Gedownload"

How should I do it and if i should enter a code where should I enter it...
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
use the afterUpdate or Change event of the checkbox, using the afterupdate event

private sub Gedowload-afterupdate()
if me.Gedowload= -1 then
   me.[Datum Gedownload] =Date()
   else
   me.[Datum Gedownload] = Null
end if

end sub
Hi Rey,

That code will work fine within Access, but I suggest that it be written to check for False or Else instead.  This logic will be more transportable to other environments like SQL Server and ASP.NET that use +1 for True.

if me.Gedowload= 0 then
   me.[Datum Gedownload] = Null
else
   me.[Datum Gedownload] = Date()
end if

Cheers,
Armen
Top Expert 2016

Commented:
yes, Armen that slips my mind when I posted the code.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and Programming
Top Expert 2015

Commented:
better than storing Yes/No for download would be to store the date/time downloaded ... and for No, it would be Null

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial