UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Barcode Reader Lines As Text, Access 2016    
 
   
bigdano
post Aug 18 2019, 10:15 AM
Post#1



Posts: 33
Joined: 20-February 17



Hello,

I am trying to use my barcode reader to import data into my form. I am using a PDF417 barcode and I need only the lines that are populated. If there is no data in a field that is duplicated I want it to pass that line and not read it. My code works well, until there is a duplication of the first three code charterers. My VBA code is as follows:

Private Sub txtReaderData2_AfterUpdate()
Dim varItem As Variant
Dim i As Integer

varItem = Split(txtReaderData2, vbCrLf)

For i = 0 To UBound(varItem)

Select Case Left(varItem(i), 3)

Case "RAM"
Me.VehiclePL = Mid(varItem(i), 4)

Case "VAD"
Me.VehicleVIN = Mid(varItem(i), 4)

Case "VAL"
Me.VehicleYR = Mid(varItem(i), 4)

Case "VAK"
Me.VehicleMK = Mid(varItem(i), 4)

End Select

Next i

End Sub

The barcode information that is being read comes from the below code:


AAMVA6360200102RG00190134TD01530063RG
RBB20190129
RAG20191231
RAMAO466
RBD
RBE
RBI
RBK
RBL
RBM
VAD1C67NM5ES276727
VAKCHEV
VAL2015
VAO
RBT20190129
RBUX551903
TD
TAC
TAA
TAV
VAL
VAK
VAD
TAF
TAU
NAA
NAE
NAR
NAT
NAU
NAV
TAG

My VBA code reads the first three digits to pick the information I want to insert, however the barcode has three codes that are duplicated. When it reads the blank codes after the filled ones it overwrites the first information and puts in a blank code into my form.

Any help would be appreciated.
Thank you

Go to the top of the page
 
cheekybuddha
post Aug 18 2019, 11:32 AM
Post#2


UtterAccess VIP
Posts: 11,487
Joined: 6-December 03
From: Telegraph Hill


Hi,

You can test whether there is a value to use before inserting:
CODE
Private Sub txtReaderData2_AfterUpdate()

  Dim varItem As Variant  
  Dim i As Integer
  Dim strVal As String

  varItem = Split(txtReaderData2, vbCrLf)

  For i = 0 To UBound(varItem)
    strVal = ""
    Select Case Left(varItem(i), 3)
    Case "RAM"
      strVal =  Mid(varItem(i), 4)
      If Len(strVal) > 0 Then Me.VehiclePL = strVal
    Case "VAD"
      strVal =  Mid(varItem(i), 4)
      If Len(strVal) > 0 Then Me.VehicleVIN = strVal
    Case "VAL"
      strVal =  Mid(varItem(i), 4)
      If Len(strVal) > 0 Then Me.VehicleYR = strVal
    Case "VAK"
      strVal =  Mid(varItem(i), 4)
      If Len(strVal) > 0 Then Me.VehicleMK = strVal
    End Select
  Next i

End Sub


However, what happens if there is a value in the second instance of the prefix?

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
bigdano
post Aug 18 2019, 01:38 PM
Post#3



Posts: 33
Joined: 20-February 17



No I am not able to test before I insert it. It populates the form once it is read. When VAL, VAD and VAK are read in order it will overwrite the prior codes with a blank. VAL, VAD and VAK have a value in the code at the top it reads them, but when it goes down and sees VAL, VAD and VAK without any codes it then posts a blank, not inputting the upper read codes. If there was a VBA code I could used to test for content after the first three characters and only use those it would work. however I have not been able to think of how to write that code. I am not a very skilled writer of Access VBA codes. I hope I am explaining this correctly.
If there is data in the second fields it will use that data to import the information into the form. However, I have not ever seen the second fields populated.
Thank you
This post has been edited by bigdano: Aug 18 2019, 01:52 PM
Go to the top of the page
 
tina t
post Aug 18 2019, 02:10 PM
Post#4



Posts: 6,075
Joined: 11-November 10
From: SoCal, USA


QUOTE
If there was a VBA code I could used to test for content after the first three characters and only use those it would work. however I have not been able to think of how to write that code.

well, that's what David posted. he tweaked your code to check for a character following the three-character code, and taking action only when finding one.

did you test David's code? if so, what were the results: error msg? wrong data in form controls? ...?

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
bigdano
post Aug 18 2019, 02:24 PM
Post#5



Posts: 33
Joined: 20-February 17



Thank you both, I should have read better. It did work.
Cheers
Dan
Go to the top of the page
 
cheekybuddha
post Aug 18 2019, 03:11 PM
Post#6


UtterAccess VIP
Posts: 11,487
Joined: 6-December 03
From: Telegraph Hill


>> If there is data in the second fields it will use that data to import the information into the form. <<

Good, the code will do that in that eventuality.

thumbup.gif

d

(ps @Tina thanks.gif)

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st September 2019 - 12:27 AM