08-11-2008, 09:40 AM
|
#2 (permalink)
|
| Member Join Date: Jun 2008 Location: London, UK
Posts: 67
Rep Power: 1  | Quote: Originally Posted by Elaine Tucker I have a table in access with a yes/no check box named "Served" and a date field named "date Served" I'd like to autopopulate the date with "today" if the checkbox is clicked AND vice-versa -- auto populate the "served?" checkbox if a date is filled in the "date served" field. Hmm. The way I'd do it (which carries one of those hefty "this might not be the right way" disclaimers is ...
Set the OnUpdate property of the checkbox control to Event. Then double-click it to go to the Event Builder, which will bring up the relevant VB window. if ChkBoxServed then DateServed=Date() You can use the same function to blank the DateServed box if the checkbox is unchecked ... if ChkBoxServed then DateServed=null Then do something similar in the event for the DateServed box ... if isNull(DateServed)=false then ChkBoxServed=True I would be tempted to start messing around with making the DateServed field disabled/locked unless the ChkBoxServed is checked, thus preventing people putting a date in without checking the box. I'd probably also chuck in a bit to then move the focus to the date box when the box is checked, to ensure that people enter a date. And a check function when the record is saved that checks whether there's a value in the date field if the check field is true. But then, I tend to try to idiot-proof my data entry if anyone other than me is going to use it. And quite often if it's just me ...
(I might be slightly off in terms of syntax, but the help files should do it - I'm slightly rusty with my Access-poking skills.)
__________________ Simon Stacey Database Officer Centrepoint |