+ Reply to Thread
Results 1 to 8 of 8

VBA Bar Coding Question

Hybrid View

jer10671 VBA Bar Coding Question 01-11-2019, 07:24 AM
Sintek Re: VBA Bar Coding Question 01-11-2019, 08:03 AM
jer10671 Re: VBA Bar Coding Question 01-11-2019, 08:33 AM
Sintek Re: VBA Bar Coding Question 01-11-2019, 08:36 AM
jer10671 Re: VBA Bar Coding Question 01-11-2019, 10:37 AM
Sintek Re: VBA Bar Coding Question 01-11-2019, 10:39 AM
jer10671 Re: VBA Bar Coding Question 01-11-2019, 01:26 PM
Sintek Re: VBA Bar Coding Question 01-11-2019, 03:37 PM
  1. #1
    Registered User
    Join Date
    10-25-2018
    Location
    USA
    MS-Off Ver
    7
    Posts
    8

    VBA Bar Coding Question

    Hello everyone - I'm using a bar code scanner to read data. When I pull the trigger on the scanner, the information is read/transferred into a text box on a form. Ideally I would like the data to go into the textbox and automatically load another form once the data is read. The original routine I had utilized a textbox_change() routine, but that didn't seem to work - as soon as the first character was read an error was generated (the data I'm inputting is a string of numbers - example 123456-00, but when pressing the trigger only the 1 would come through, then error is generated). I tried putting a pause in there so that the whole string could be read, but then nothing would happen. So then I changed to a textbox_afterupdate() routine. This initially works, but for some reason it only works 1 time, then I'm forced to close that form in order to have my routine continue.

    The code I was using with the textbox_change() routine is below:

    Private Sub txtJobNumber_Change()
         Call OpenWorkbook
    End Sub
    The OpenWorkbook routine will close the current form, then open another form - I know this code works the way I want it to if I enter the number string manually then hit enter. But it doesn't work in conjunction with the bar code scanner.

    The code I'm currently using with the textbox_afterupdate() routine is below:

    Private Sub txtJobNumber_AfterUpdate()
       If txtJobNumber.Text <> "" Then
            Call cmdScanJobEnter_Enter
        End If
    End Sub

    I've added a command button to the form which when pressed calls the OpenWorkbook routine. As I said, this code works as desired, however it will only work once, then I'm forced to close the form after the number string is read from the barcode scanner in order to have my process continue.

    Does anyone have any experience using bar code scanners with VBA, or has anyone had similar issues? How have you been able to overcome this? Any suggestions would be appreciated.

    Thanks in advance!
    Last edited by jer10671; 01-11-2019 at 08:32 AM.

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA Bar Coding Question

    Hi jer10671

    Unfortunately not able to assist as your post does not comply with the forum rules...Please take some time to read them..
    2. Programming code must be enclosed in code tags to improve readability. (A, Z)
     Your Code
    (or use the # button)

    So, do the following:
    Edit your post, highlight your code and click the [#] button at the top of the post window.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    10-25-2018
    Location
    USA
    MS-Off Ver
    7
    Posts
    8

    Re: VBA Bar Coding Question

    Thank you - I didn't know how to do that.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA Bar Coding Question

    This works for me...

    Option Explicit
    
    Private Sub txtJobNumber_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    If Len(txtJobNumber.Text) <> 0 Then
        Call cmdScanJobEnter_Enter
        txtJobNumber = ""
        Cancel = True
    End If
    txtJobNumber.SetFocus
    End Sub

  5. #5
    Registered User
    Join Date
    10-25-2018
    Location
    USA
    MS-Off Ver
    7
    Posts
    8

    Re: VBA Bar Coding Question

    Thank you - no luck though. Still running into the same issue as my current code.

    Basically what I'm trying to achieve is when the textbox gets populated, it triggers an event. Not having any luck though.
    Last edited by jeffreybrown; 01-11-2019 at 01:42 PM. Reason: Please don't quote full posts!

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA Bar Coding Question

    I assume that this part...is the event?
    Call cmdScanJobEnter_Enter
    What is the code within ...Perhaps you should upload as ample file...

  7. #7
    Registered User
    Join Date
    10-25-2018
    Location
    USA
    MS-Off Ver
    7
    Posts
    8

    Re: VBA Bar Coding Question

    I think I figured this out... one thing I should have added is that the command button (cmdScanJobEnter) was not visible. However if I make it visible, as soon as I scan the information and it's transferred into the text box, there is a very slight pause, then the call routine which is triggered by the command button is activated/run. Don't ask me why this is so, but it is. I have it working now, just had to make the command button visible (I put it behind a label so it's not visible to the user, but visible to the program/VBA - if that makes sense.

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: VBA Bar Coding Question

    glad you got it figured...tx for rep...if your question is answered, please mark thread as solved...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Coding Question
    By bbaynard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2015, 08:51 PM
  2. Coding Question
    By JayT61 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2012, 03:57 AM
  3. VBA coding question
    By Zimmerman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-02-2010, 12:48 PM
  4. VBA coding question
    By mcinnes01 in forum Access Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2010, 01:04 PM
  5. Subtotal in VBA, coding question
    By D3Pratt in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-03-2009, 02:54 PM
  6. Question about merging, coding and the like
    By MichelleFinn in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-06-2008, 06:49 PM
  7. Coding question
    By bach in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2005, 03:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1