Automatic date insertion.

D

Dave

Hi,
Access 2003
I am very new to Access, so please keep your explanations simple.
I have a table with 4 fields:
ID - Autonumber
Scanner - Text
Date - Date/Time, formatted Medium Date
Time - Date/Time, formatted Short Time
I have a barcode scanner hooked to the computer.
Currently, when I scan a barcode, the scanned data goes into whatever field
has the curser flashing in it, and the curser jumps to the next field. I
think the jumping to the next field bit, is done by the scanner.
What I would like, is to start with the curser flashing in the Scanner
field, scan a barcode, which inputs the barcode data, then advances the
curser to the Date Field, then have Access automatically fill in the Date
field with the current date, then go on to the Time field and fill that in
with the current time, then go to the scanner field on the next record, ready
for the next scan.
Is this possible?
Regards - Dave.
 
D

Duane Hookom

Change your Date and Time fields so they are not reserved words. Both Date
and Time are function names. If you want to store the date/time a record was
created, use one field named ScanDateTime and set its default to Now().

Create a form with one enabled control bound to the Scanner field. The ID
and ScanDateTime will automatically be populated when the Scanner field is
completed and you move to the next record.
 
D

Dave

Hi Duane,
I think I did what you suggested, but the current time seems to go into new
(un-used) record, and the time for the previous scan goes into the scan just
done.
Dave.
 
D

Dave

Hi Steve,
Thanks for your response.
I have done as you suggested, but I have 2 problems.
After each scan, the curser moved UP one record instead of down.
I tried to put a break point into the code, to see where that was happening
(like I do in XL. Ahhh, XL) but I got an error:
Run-time error '3021':
No current record.
This occurred on line:
Me.Bookmark = Rst.Bookmark
So I took the breakpoint out, but it still errors there every scan.
Regards - Dave.
 
D

Duane Hookom

I would test this to make sure. If you aren't getting the actual record
creation date/time, you could add a little code to the after update of the
scanner text box like:

Me.txtDateTime = Now()
 
D

Dave

Thanks to both of you. This is a work thing, so I'll have to try again
Monday. I'll let you know how it goes.
Regards - Dave.

Steve said:
Dave,

Let's see if your scanner is automatically advancing to the next record. Go
into your code and keep the first two lines:
Me![NameOfDateField] = Date()
Me![NameOfTimeField] = Time()

and put a single quote in front of each of the other lines. Doing this
comments out those lines of code so they do not execute. Now do a scan and
report back what happened.

Steve
(e-mail address removed)





Dave said:
Hi Steve,
Thanks for your response.
I have done as you suggested, but I have 2 problems.
After each scan, the curser moved UP one record instead of down.
I tried to put a break point into the code, to see where that was
happening
(like I do in XL. Ahhh, XL) but I got an error:
Run-time error '3021':
No current record.
This occurred on line:
Me.Bookmark = Rst.Bookmark
So I took the breakpoint out, but it still errors there every scan.
Regards - Dave.
 
D

Dave

Hi Duane,
Got back to work and tried again. Your way worked (of course). Sorry about
that. I'll get there eventually. Thanks for your help. Probably won't be the
last time I need it.
Regfards - Dave.
 
D

Dave

Hi Steve,
I tried again and got the thing working ok using Duanes post. I'll leave it
at that for now, but will probably be back soon enough with other questions.
Thanks for your help.
Regards - Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top