Results 1 to 7 of 7
  1. #1
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24

    Identifier for barcode scanner


    Hi, im trying to work with a barcode scanner in access. The problem i got is that there are 2 text boxes. One with a locationID and one with a productID. Both barcodes got a identifier like $ and %. example: $A2E as location and %000323 as productID

    Now i want access to identify the barcode and put it in the right text box.

    I know i need a if statement and some kind of function that looks for a string. But i have no idea where to begin .

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Something along the lines of:

    Code:
    If Left(YourInput, 1) = "$" Then
       'put it one place
    Else
       'put it in the other
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    Ok, im not getting it i got this in "before input" for testing :
    Code:
    Private Sub Form_BeforeInsert(Cancel As Integer)   
     If Left(Yourinput, 1) = "A" Then
        MsgBox ("test1")
            Else
       MsgBox ("Test2")
        End If
    
    
    End Sub
    Where do i need to do with yourinput? or is this a function?

  4. #4
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    Got it working, but it does not refresh when the data is copied(The textbox stays empty until i select it). Anyidea how i can refresh the the text fields? I tried me.Refresh but it didn't work

    Code:
    Private Sub Tekst800_AfterUpdate()    If Left(Me.Tekst800, 2) = "/D" Then
    
    
        Me.Tekst837.Value = Right(Me.Tekst800.Value, 3)
        Me.Tekst829.Value = Mid(Me.Tekst800, 6, 1)
        Me.Tekst823.Value = Mid(Me.Tekst800, 3, 3)
        Me.Tekst800.Value = ""
           Me.Tekst800.SetFocus
        
            Else
       Me.Keuzelijst783.Value = Mid(Me.Tekst800.Value, 3, 20)
       Me.Tekst800.Value = ""
           Me.Tekst800.SetFocus
       
        End If
    
    
           
    End Sub

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You mean the textboxes where you're placing values? I'd expect them to fill in. Can you attach the db here with sample values that would get scanned?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Carloj is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    24
    It's kinda weird but this does the trick:
    Code:
    Private Sub Tekst800_AfterUpdate()    If Left(Me.Tekst800, 2) = "/D" Then
        Me.Tekst837.Value = Right(Me.Tekst800.Value, 3)
        Me.Tekst829.Value = Mid(Me.Tekst800, 6, 1)
        Me.Tekst823.Value = Mid(Me.Tekst800, 3, 3)
        Me.Tekst800.Value = ""
    Me.Keuzelijst783.SetFocus
           Me.Tekst800.SetFocus
        
            Else
       Me.Keuzelijst783.Value = Mid(Me.Tekst800.Value, 3, 20)
       Me.Tekst800.Value = ""
    Me.Keuzelijst783.setFocus
           Me.Tekst800.SetFocus
    
       
        End If
    
    
            End Sub

  7. #7
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    You can't set focus to the control you are running event code from. It would allow you to easily set up a endless loop.
    As you have done simply move to another control, or probably better goto to a confirm button to restart the process?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Barcode scanner and click event
    By BigJohn89 in forum Programming
    Replies: 4
    Last Post: 05-03-2018, 02:17 AM
  2. Barcode Scanner Invalid Scan
    By nick243 in forum Access
    Replies: 2
    Last Post: 06-13-2016, 02:09 PM
  3. How can a barcode scanner autofill fields
    By Business in forum Programming
    Replies: 5
    Last Post: 05-26-2016, 11:01 AM
  4. Barcode scanner
    By Business in forum Programming
    Replies: 1
    Last Post: 05-22-2016, 08:48 AM
  5. Barcode scanner for small project
    By miziri in forum Programming
    Replies: 7
    Last Post: 05-20-2011, 01:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums