Hi, I'm very new to Access...my company decided we need to have a database and I'm somehow trying to get my arms around this...
I'm using a 2003 version of Microsoft Access running on Windows Vista. I would like to know how I can set up an automatic end date. I'll explain:
I have a 'task' table which, among others, includes two fields: Active and End Date. The "Active" field is a simple Yes/No data type; when I check off the Active box, the task disappear from a related 'task' form. I would like Access to generate automatically an End Date every time I check off an Active box. Obviosuly, the end date should be current day/month/year and should appear in the "End Date" field.
How can I do this?
I've browsed the website looking for similar posts, but haven't found any. If I've missed it, it would be great if you could point me to that.
Many thanks for your help!
Mattia
Mattia,
Simply put, you'd have to set the value for the field EndDate when the value of Active is set to true.
I'm assuming first of all that you have this table displayed in a form, and you're not updating the table directly in the table view?
I'm also assuming that if you are updating the information, that you're using a continuous form, or a form that has the "Active" field in it, and may or may not have the "EndDate" field on that form.
If either of those are true then here's what you need to do:
1. Go into design mode of the form
2. right-click on the CheckBox and select Properties.
3. Locate the "On Change" Event from the list of the available events
3. Then click on the ... button that is on the far right of Properties window, and select Code Builder.
4. You will then see a empty subroutine for "Active_OnChange" Event.
5. In the middle of that copy and paste the following code:
-
-
If me.active = True Then
-
me.EndDate = Date
-
Else
-
me.EndDate = Null
-
End If
-
-