Autocomplete in Access 
July 2nd, 2009, 03:38 PM
| | Newbie | | Join Date: May 2009
Posts: 9
| | |
Hi
In my database I have a table to record absence. The table has a start date column and an end date column. As staff seem to often have one day bugs (a seperate issue to work out!!), I would like the end date column to automatically populate with the date that was put in the start column. But also allow it to be written over should they have something more serious!
I'm fairly new to access still, so hopefully its not too complex?
Thanks in advance for your help!!
| 
July 2nd, 2009, 04:14 PM
|  | Needs Regular Fix | | Join Date: Aug 2007
Posts: 279
Provided Answers: 1 | | | re: Autocomplete in Access
Hi Fluffy,
Personally, I would prompt the user. That way they can have the choice to populate it with the date or not and you won't have to worry about whether the user won't be able to overwrite the date that is populated.
I would use something like the following code to achieve this: -
Private Sub StartDate_AfterUpdate()
-
If vbYes = MsgBox("Is the end date the same as the start date?", vbYesNo) then
-
EndDate = StartDate
-
Else
-
'Do Nothing
-
End If
-
End Sub
-
| 
July 2nd, 2009, 09:15 PM
|  | Moderator | | Join Date: Nov 2006 Location: Richmond, Virginia USA
Posts: 2,970
Provided Answers: 11 | | | re: Autocomplete in Access
Nothing at all wrong with doing that, especially if the absence StartDate and EndDate are not always entered at the same time. This allows the date to be overwritten: -
Private Sub StartDate_AfterUpdate()
-
Me.EndDate = Me.StartDate
-
End Sub
Welcome to Bytes!
Linq ;0)> | 
July 3rd, 2009, 04:15 PM
|  | Needs Regular Fix | | Join Date: Aug 2007
Posts: 279
Provided Answers: 1 | | | re: Autocomplete in Access Quote:
Originally Posted by missinglinq Nothing at all wrong with doing that, especially if the absence StartDate and EndDate are not always entered at the same time. This allows the date to be overwritten: -
Private Sub StartDate_AfterUpdate()
-
Me.EndDate = Me.StartDate
-
End Sub
Welcome to Bytes!
Linq ;0)> | Good call Linq. I thought about that, but I work with users that get complacent when things are done for them so I went this route instead. Either way, they're two good options to choose from.
| 
July 3rd, 2009, 06:49 PM
|  | Moderator | | Join Date: Nov 2006 Location: Richmond, Virginia USA
Posts: 2,970
Provided Answers: 11 | | | re: Autocomplete in Access
My signature
There's Always more than one way to skin a cat!
kind of says it all! I try to stress, where appropriate, that many posters' situations are unique to them, and that [b]absolutely, positively don't/B]... should only be used when talking to your kids about drugs and alcohol! There are simply too many variables where absolutes don't apply. And the same goes for people responding to posts. Everyone trying to help is doing so based on their experiences. And you have to always keep that in mind!
Linq ;0)> |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,652 network members.
|