Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2003, 05:38 AM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access begginer, how to autoenter time/date

Hi everyone

I just started learning Access and I am building a simple database.

I have one form with 3 fields (ID, current date and current time). I'll be using barcode reader to input numbers in ID field and date and time have to be current, meaning the exact time when ID was logged. I also don't want to allow changes in time and date field by user (i figured this one out - properties/data/enabled-no).

My problem is that barcode reader reads the ID and also sends "enter" command to computer, so new record is immediatly opened. How can I setup so that current date and time are inputed before new record is opened, actually when ID was read.

I managed with expression builders to populate date and time filed, but I only managed to get date and time when new record was created, not when it was 'closed' (ID was entered) and this is the time that I need.

Thanks in advance

 
Old August 11th, 2003, 06:38 AM
Authorized User
 
Join Date: Jul 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Stompy,
I'd have thought you would be better with just one date/time field formatted in the table as General Date. With this, on the form in design view, double click the ID control(text box) - scroll down the properties list to the After Update event and click in it. Click on the button on the right with the '...' and choose Code (if you're offered a choice).
If you copy the middle line as below but substitute the name for your date/time field for 'Date_Time'(keep the 'Me.') then I hope you'll find that before your database moves to a new record the values will be put in the required data/time field.

Private Sub ID_AfterUpdate()
Me.Date_Time = Now()
End Sub

I haven't got a barcoder so I can't be 100% sure it'll work in your case. Maybe some of the more experienced on the forum might have some better ideas.
cheers
Morris

 
Old August 11th, 2003, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

You can either assign the date/time value via the ID's AfterUpdate event the way Morris instructed or simply set the date/time field's default property to =Now(). This would require no AfterUpdate coding.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old August 14th, 2003, 09:08 AM
Authorized User
 
Join Date: Jul 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,folks,
Greg - if there was a delay before recording the next ID, would the Now() function in the default property read the date/time that the record was opened and not the time the barcoder was used or have I got hold of the wrong end of the stick here?

 
Old August 14th, 2003, 09:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Morris,

The Now() function will use the time that the Access record was actually opened, not when the barcoder took a reading. For the date and time to reflect that, your barcoder will have to store that time in itself and send it to Access.

Also, note that the now in Now() is the time your computer clock says. So if your computer clock is wrong, Now() is wrong, too. And if your barcoder has its own clock, that has to be calibrated, too.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
Using Date time picker in access 2003... aboredman Access 1 August 9th, 2007 08:58 PM
sending date and time to access database Yasho VB.NET 2002/2003 Basics 3 May 24th, 2007 12:59 AM
Syntax to query Date/Time in MS ACCESS chiuyianl Access 4 March 31st, 2005 09:08 AM
Convert Text to Date/Time in Access mmcdonal Access VBA 7 June 15th, 2004 12:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.