Repeated data count in form entry???

G

G Lam

Hi, I have a data input form for bar code data entry. The associated table
only have two fields - Bcode and Qty. I wrote two lines of code in
AfterUpdate Event for the Bcode control in input form like this:

Private Sub Bcode_AfterUpdate()
Qyt = 1
DoCmd.GoToRecord , , acNewRec
End Sub

It works fine; whenever the bar code scanner captures a barcode the qty
field change to 1 and go to a new record and wait for the next scan.
However, before long, the table grows very big, because one record for one
scan. How can I just increment the Qty by 1 if the bar code is the same. If
the bar code changes, add a new record and insert the new bar code to the
new record?
Thank you in advance.
Gary
 
D

david epsom dot com dot au

if it is a bound control then

if me.Bcode <> me.Bcode.oldvalue then
qty = 1
DoCmd.GoToRecord , , acNewRec
endif


(air code)

(david)
 
G

G Lam

Hi, David,
Thank for your reply. Could you tell me a little bit more about this line of
code? What is the me.Bcode.oldvalue refered to?
Thank you.
Gary
 
D

david epsom dot com dot au

Oldvalue is a control property.
Bcode is a control name -- I got the name from your example event code.
Me is a reference to the form which has the event code and the control.

Although OldValue is a property of all textbox controls, it is only valid
for bound controls: it refers to the <Old> bound value, before you started
the update.


(david)
 

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

Similar Threads


Top