Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25

    Barcode Scanning

    All my jobs have barcodes. The scanner is set to Tab. I works great!



    Here is what I would like to be able to do.

    When a worker bills out a job they scan the Job Number, next a suggested price is displayed in the proper field. (Thanks to the fine programers on this site).

    They have the choice of accepting the shown price by using the Enter Key on the Keyboard or can manually enter their price in using the numeric keyboard and hitting enter.

    What I would like is to be able to use the scanner to simulate the Enter Key

    Have no idea how to code that, or where to code that, if it is a setting in the scanner itself

    Keep in mind the Price field is ready to accept new input or Enter.

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    The barcode scanner simulates a keyboard input, so if you scan anything it would overtype the contents of the number, the only way around that would be to scan a unique "thing", and capture it.

    So you print off a barcode label that says "@BigBen_Pyramid#" or something equally unlikely, stick that on the operators bench.
    In the before update event of your price field you do something like

    Code:
    If me.yourpricefield ="@BigBen_Pyramid#" Then
        me.yourpricefield = me.yourpricefield.oldvalue ' to get back the value that was there
        Me.TheNextControlYouGoTo.SetFocus ' to move on to where you want to go to
    End If
    This is all air code but hopefully steers you in the right direction.

    If it will only take a number in the price field (quite possibly) then try putting in -0.99 or something else that wouldn't ever be likely to appear as a price.
    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 ↓↓

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    the barcode scanner should come with a sheet of 'programming' barcodes,
    1 would be 'add CR at post scan'. scan this and it programmatically adds the CR to itself.

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by ranman256 View Post
    the barcode scanner should come with a sheet of 'programming' barcodes,
    1 would be 'add CR at post scan'. scan this and it programmatically adds the CR to itself.
    Normally though you still need to scan something valid as a barcode for the scanner to register and send a value.

    Just scanning thin air won't send anything. In my experience.
    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 ↓↓

  5. #5
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Here is the code entered and the result.

    Run-time error '2147352567 (800200009)
    The macro of function set to the BeforeUpdate of ValidationRule property for this field is preventing Job Tracking (name of my program) from saving the data in the field.

    This is what debugger showed.

    Private Sub Amount_BeforeUpdate(Cancel As Integer)
    If Me.Amount = "99999991" Then
    Me.Amount = Me.Amount.OldValue ' to get back the value that was there
    Me.Job_Number.SetFocus ' to move on to where you want to go to
    End If
    End Sub

    This isn't a ValidationRule for Amount

    Thanks for your help

  6. #6
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Would this change to Scanner setting to Enter, or leave it at Tab (as it is) and would act in the same manner as the enter key on the Keyboard?

  7. #7
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Would this change to Scanner setting to Enter, or leave it at Tab (as it is) and would act in the same manner as the enter key on the Keyboard?

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    It shouldn't make any difference as tabbing out of a control or hitting enter is effectively the same thing unless the control enter key property is set to "enter a newline".

    Try instead

    Code:
    Private Sub Amount_BeforeUpdate(Cancel As Integer)
        If Me.Amount =  99999991  Then  ' I have removed the quotes as I assume its a number?
             Me.Undo 'to get back the value that was there
             Me.Job_Number.SetFocus ' to move on to where you want to go to
        End If
    End Sub
    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 ↓↓

  9. #9
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Thanks for not giving up on me. I really want this to work! I'm trying to give you as must information as I can.
    Thanks RandyH
    -------------------------------------------------------------------------------------------------------------

    Here is the code I entered and this is what Debugger didn't like.

    Run-Time error '2108':

    You must save the field before you execute the GoToControl action,
    the GoToControl method , or the SetFocus method.

    (Tried to run the code w/o Me.Job_Number.Set Focus, but that resulted the deletion of values in all fields. As if the data was never entered.



    Private Sub Amount_BeforeUpdate(Cancel As Integer)


    If Me.Amount = 99999991 Then
    Me.Undo
    Me.Job_Number.SetFocus ' to move on to where you want to go to


    End If
    End Sub

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


    This may be a factor to consider?

    Set in [Amount] Properties:

    On Lost Focus DataEntry (The keyboard Enter Key?)




    Private Sub Amount_Enter()


    Me.Amount = DLookup(" ([setter price]+[polisher price])", "qrynewbillingtoseecodessetter")


    End Sub

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

    It appears that Tab Order [Job Number] is 0 and [Amount] is 1, then back to 0 on Keyboard Enter Key.



    Thanks

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Okay I'll now do this by actually writing the code, rather than shooting from the hip.

    It's a bit simpler than I thought

    Code:
        If Me.Amount = 9999999991 Then
            Me.Amount.Undo
        End If
        Cancel = False
    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 ↓↓

  11. #11
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Thanks. Please don't give up! You are so close.

    I'm not getting any error messages, but the value returned and overwriting OldValue is $99,999,991.00

    [Table1].[Amount] Date Type is Currency

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Does the figure in the if statement match the scanned value? Add a debug to check


    Debug.Print "Scanned value: " & Me.Amount
    If Me.Amount = 9999999991 Then
    Me.Amount.Undo
    End If
    Cancel = False
    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 ↓↓

  13. #13
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Here is the Error Message

    The value you entered isn't valid for this field.

    For example, you may have entered a text in a numeric field or a number that is larger than the
    FieldSize.

    So I changed to number from 99999991 to 191919 hoping that would end the error message:

    The result was the same, showing $191,919.00 in Me.Amount Field and saving record as $1,919.00



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


    Here is the code that I have now

    Debug.Print "191919: " & Me. Amount
    If Me.Amount = 191919 Then
    Me.Amount.Undo

    End IF Cancel = False
    ------------------------------------------------------------------------------------------------------------------------

    I really appreciate all you help.
    RandyH

  14. #14
    RandyH is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2020
    Posts
    25
    Also tried this:

    Debug.Print "Scanned value: " & Me.Amount
    If Me.Amount = 191919 Then
    Me.Amount.Undo
    End If
    Cancel = False


    Same Error message and record disappears completely.

  15. #15
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    So in the immediate window in the VBA Editor what was the debug message ? (Press ctrl + G to bring it up)

    Do you have an input mask on the amount control by any chance?
    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 ↓↓

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. check barcode serial number before scanning
    By hullstorage in forum Programming
    Replies: 1
    Last Post: 07-14-2020, 06:33 AM
  2. Replies: 5
    Last Post: 05-16-2019, 09:01 PM
  3. Replies: 2
    Last Post: 11-10-2017, 04:38 AM
  4. Employee time clock with barcode scanning
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 03-26-2014, 10:54 PM

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