By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,315 Members | 1,611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,315 IT Pros & Developers. It's quick & easy.

Autocomplete in Access

P: 11
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!!
Jul 2 '09 #1
Share this Question
Share on Google+
4 Replies


beacon
100+
P: 579
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StartDate_AfterUpdate()
  2.      If vbYes = MsgBox("Is the end date the same as the start date?", vbYesNo) then
  3.           EndDate = StartDate
  4.      Else
  5.           'Do Nothing
  6.      End If
  7. End Sub
  8.  
Jul 2 '09 #2

missinglinq
Expert 2.5K+
P: 3,532
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StartDate_AfterUpdate()
  2.   Me.EndDate = Me.StartDate
  3. End Sub
Welcome to Bytes!

Linq ;0)>
Jul 2 '09 #3

beacon
100+
P: 579
@missinglinq
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.
Jul 3 '09 #4

missinglinq
Expert 2.5K+
P: 3,532
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)>
Jul 3 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.